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;