<% @ Page contenttype = "text/html; charset = GBK" Language = "Java" Import = "Java. SQL. * "errorpage = ".. /error. JSP "%>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = GBK">
<Title> </title>
</Head>
<%
String id = request. getparameter ("ID ");
String Password = request. getparameter ("password ");
String info = "0 ";
Connection con = NULL;
Statement Sm = NULL;
Resultset rs = NULL;
Try
{
Class. forname ("com. MySQL. JDBC. Driver"). newinstance ();
String url = "JDBC: mysql: // localhost/mydb1 ";
Con = drivermanager. getconnection (URL, "root", "admin ");
Sm = con. createstatement ();
Rs = sm.exe cutequery ("select * From userinfo where userid = '" + ID + "'");
If (Rs. Next ())
{
If (Rs. getstring ("password"). Equals (password ))
{
Response. sendredirect ("../index. jsp ");
Session. setattribute ("user", ID );
}
Else
Response. sendredirect ("login. jsp? Info = 2 ");
}
Else
{
Response. sendredirect ("login. jsp? Info = 1 ");;
}
}
Catch (exception E)
{
E. printstacktrace ();
}
Finally
{
If (RS! = NULL)
{
Try {Rs. Close ();} catch (exception e) {e. printstacktrace ();}
}
If (SM! = NULL)
{
Try {SM. Close ();} catch (exception e) {e. printstacktrace ();}
}
If (con! = NULL)
{
Try {con. Close ();} catch (exception e) {e. printstacktrace ();}
}
}
%>
<Body>
</Body>
</Html>