JSP User Login code (full login instance)

Source: Internet
Author: User

Web effects phttp://www.111cn.net/Web effects p.html target=_blank >jsp Tutorial User Login code (full login instance)
Here we provide the use of Java for user login code, from the HTML, to the database tutorial and JSP are step-by-step written very clearly, if you are JSP beginners to see if this user landing is not suitable for you, good not to say much to see this user login code bar.

<form name= "Form1" method= "Post" action= "login.jsp" >
<p>
<label for= "username" ></label>
<input type= "text" name= "username" id= "username" >
</p>
<p>
<label for= "Passwrod" ></label>
<input type= "text" name= "Passwrod" id= "Passwrod" >
</p>
<p>
<input type= "Submit" name= "button" id= "button" value= "submitted" >
</p>
</form>


login.jsp Code

<%
    String name = Request.getparameter ("username");
    string pwd = Request.getparameter ("password");
   //out.println (NAME+PWD);
    String sql = "SELECT * from info where username= '" +name+ "' and Password= '" "+pwd+" ";
   //out.println (SQL);
    statement stm= null;
    resultset rs =null;
    try
    {
        stm = conn.creates Tatement ();
        rs = stm.executequery (SQL);
        if (Rs.next ())
        {
            Session.setattribute ("username", name);
            response.sendredirect ("Index.hTml ");
       }
        Else
        {
 & nbsp;          response.sendredirect ("index1.html");
       }
   }
    catch (SqlException e)
    {
         E.printstacktrace ();
   }
%>

Info table

CREATE table if not EXISTS ' test ' (
' ID ' int (8) NOT NULL auto_increment,
' Username ' char ($) default NULL,
' Password ' varchar (32),
' Times ' int (4) is not NULL,
Primary KEY (' ID ')
) Engine=myisam default Charset=utf8 auto_increment=1;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.