Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

failure to log in

Ads

 
 

Share on Google+Share on Google+

boifang
failure to log in
1 Answer(s)      6 years and 5 months ago
Posted in : JSP-Servlet
<blockquote>
  <p>Blockquote</p>
</blockquote>

<p>&lt;[email protected] contentType="text/html"%>
&lt;[email protected] pageEncoding="UTF-8"%>
&lt;[email protected] import="java.sql.Connection" %>
&lt;[email protected] import="java.sql.DriverManager" %>
&lt;[email protected] import="java.sql.Statement" %>
&lt;[email protected] import="java.sql.ResultSet" %>
&lt;[email protected] import="java.sql.PreparedStatement" %>
&lt;[email protected] import="java.sql.SQLException" %></p>

<p><html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>Login</title>
    </head>
    &lt;%
        String userName = request.getParameter("username");
        String password = request.getParameter("password");
        String rm<em>me = request.getParameter("rm</em>me");
        String rm<em>uname = request.getParameter("rm</em>uname");</p>

<pre class="prettyprint">    if (userName != null &amp;&amp; password != null) {
        if (rm_me != null) {
            Cookie ckU = new Cookie("username", userName);
            Cookie ckP = new Cookie("password", password);
                   response.addCookie(ckP);
        } else {
            if (rm_uname != null) {
                Cookie ckU = new Cookie("username", userName);

            }
        }

        try {

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

            Connection conn = DriverManager.getConnection("jdbc:odbc:mydsn","sa","[email protected]");

            String sql = "select customer_id, fname, lname, email_id, phone_number from customer_details where user_name=? and password=?";
            PreparedStatement stmt;

            ResultSet rs = stmt.executeQuery();

            if (rs.next()) {
                session.setAttribute("customerId", rs.getString(1));
                session.setAttribute("userName", userName);
                session.setAttribute("fName", rs.getString(2));
                session.setAttribute("lName", rs.getString(3));
                session.setAttribute("emailId", rs.getString(4));
                session.setAttribute("phoneNumber", rs.getString(5));
                conn.close();
          %&gt;
                &lt;jsp:forward page="welcome.jsp" /&gt;
          &lt;%} else {%&gt;


        Sorry! You have entered an invalid username or password. Please try again.
          &lt;%}
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
%&gt;
&lt;body&gt;
    &lt;p&gt; &lt;/p&gt;
    &lt;p&gt; &lt;/p&gt;
    &lt;p&gt; &lt;/p&gt;
    &lt;p&gt; &lt;/p&gt;

    &lt;%
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (int i = 0; i &lt; cookies.length; i++) {
            if (cookies[i].getName().equals("username")) {
                userName = cookies[i].getValue();
            }
            if (cookies[i].getName().equals("password")) {
                password = cookies[i].getValue();
            }
        }
    }
    %&gt;

    &lt;form name="LoginForm" id="LoginForm" method=post Action="login.jsp"&gt;
        &lt;table width="70%" align="center" border="1"&gt;

            &lt;tr&gt;
                &lt;td&gt;&lt;img src="logo.jpg"&gt;&lt;/img&gt;&lt;/td&gt;
                &lt;td&gt;Lets conserve our environment&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td align="center"&gt;User Name&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="username" maxlength="50" value="&lt;%=(userName==null?"":userName)%&gt;"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td align="center"&gt;Password&lt;/td&gt;
                &lt;td&gt;&lt;input type="password" name="password" maxlength="100" value="&lt;%=(password==null?"":password)%&gt;"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td&gt; &lt;/td&gt;
                &lt;td&gt;
                    &lt;input type="submit" name ="login" value="Login" /&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td align="center"&gt;
                    &lt;input type="checkbox"  name="rm_uname" value="RememberUsername" /&gt;Remember Username
                &lt;/td&gt;
                &lt;td&gt;
                    &lt;input type="checkbox"  name="rm_me" value="RememberMe" /&gt;Remember Me
                &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/table&gt;
    &lt;/form&gt;
&lt;/body&gt;
</code></pre>

<p></html></p>

<blockquote>
  <p>Blockquote</p>
</blockquote>

<p>can someone help to identify the error because even when the username and password are provided the error message appers indicating failure to loggin. </p>
Ads
Ads









Related Tutorials/Questions & Answers:
failure to log in
failure to log in  <blockquote> <p>Blockquote</p> </blockquote> <p>&lt;[email protected] contentType="text/html"%>... failure to loggin. </p>   Please visit the following links: http
build failure error with maven
build failure error with maven  hi, when i clean install a maven file I am getting the error in command prompt like sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release. There are several
Advertisements
log in
log in  sir i designed one login.jsp page with one form, username,login,and one submit button .if i enter username and password its been verify the mydatabase in in table in the field of username and password while it s correct
Describe the effects of a server failure on the application
Describe the effects of a server failure on the application Prev  Chapter 7. Validate, tune and troubleshoot... Describe the effects of a server failure on the application
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Communications link failure due to underlying exception
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Communications link failure due to underlying exception  Hi, In my application...: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Communications link failure due to underlying exception: Tell me how
if my database(oracle) connection failure means wat is the code to write in exception ?
if my database(oracle) connection failure means wat is the code to write in exception ?  if my database(oracle) connection failure means wat is the code to write in exception
Log-in Valdidation
Log-in Valdidation  how to create login validation in jsp
log out
log out  how do i create a log out on a project without it exiting system so it does not reload again
How to detect system failure using java code - Java Beginners
How to detect system failure using java code  I am doing a project... to detect the process that make failure. I have no idea about the project so please help me. And i need some site to download java source code
log 4j
log 4j  what is log4j? can you give me clear information about log4j?   Please go through the following link: log4j Tutorials
error log
error log  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details-------------- Table
Writing Log Records to a Log File
Writing Log Records to a Log File       This section demonstrates for writing log records to a log file. Logger provides different types of level like: warning, info
log in page
log in page  hi all i want to create a login page in jsp which should be validated using ajax. please help me dong that with code...   Here is a jsp example that accepts username and password from the user and check
Version of com.techshroom>Log dependency
List of Version of com.techshroom>Log dependency
Version of taglibs>log dependency
List of Version of taglibs>log dependency
Version of co.trikita>log dependency
List of Version of co.trikita>log dependency
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
keeping log of page load - Java Beginners
to keep a log of if the page has succesfuuly loaded or not. It means I want to keep log for sucess and failure both for page loading. Can you please give me some...keeping log of page load  Hello, I have a project and I need
Artifacts of com.splinter-log
List of Artifacts of com.splinter-log maven depenency
error log and send Database
error log and send Database  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details
Version of com.logicartisan>log-indexer dependency
List of Version of com.logicartisan>log-indexer dependency
Version of taglibs>log-doc dependency
List of Version of taglibs>log-doc dependency
Version of com.17jee>e-log dependency
List of Version of com.17jee>e-log dependency
Version of com.amlinv>log-utils dependency
List of Version of com.amlinv>log-utils dependency
Version of com.logicartisan>log-indexer dependency
List of Version of com.logicartisan>log-indexer dependency
Version of com.lukekorth>mailable_log dependency
List of Version of com.lukekorth>mailable_log dependency
Version of com.mycila>mycila-log dependency
List of Version of com.mycila>mycila-log dependency
Version of taglibs>log-examples dependency
List of Version of taglibs>log-examples dependency
Version of com.globalmentor>globalmentor-log dependency
List of Version of com.globalmentor>globalmentor-log dependency
Version of com.identityblitz>log-lib dependency
List of Version of com.identityblitz>log-lib dependency