Create a database (std. mdb) with two tables 1.pw( password table). 2. score two tables.
Create two Jsp files
Enter. jsp (logon page, used for positive identity verification)
-----------------------------------------------
<% @ Page contentType = "text/html; charset = gb2312" %>
<Html>
<Title> logon with personal score query </title>
<Body>
<Center>
<Font color = blue size = 4> <B> <I>
Enter your student ID and password </B> </I>
</Font>
<Hr>
<Form action = "result. jsp" method = "post">
<Table border = "1">
<Tr> <th bgcolor = "yellow"> Student ID </th> <td>
<Input type = "text" size = 10 name = "number"> </td> </tr>
<Tr> <th bgcolor = "yellow"> password </th> <td>
<Input type = "password" size = 10 name = "password"> </td> </tr>
<Tr> <td colspan = "2" align = "center">
<Input type = "submit" vaule = "query"> </td> </tr>
</Table>
</Form>
<Font color = "red">
<%
String error = request. getParameter ("errortype ");
If (error! = Null)
{
Int errortype;
Errortype = Integer. parseInt (error );
Switch (errortype)
{
Case 1: out. println ("Enter your student ID! "); Break;
Case 2: out. println ("enter the password! "); Break;
Case 3: out. println ("wrong, no such person! "); Break;
Case 4: out. println ("Incorrect password! "); Break;
Default:
}
}
%>
</Font>
</Body>
</Html>
Result. jsp (query result execution)
--------------------------------------------
<Html>
<Title> query result </title>
<Body>
<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. SQL. *" %>
<%
String num = request. getParameter ("number ");
String password = request. getParameter ("password ");
Int errortype = 0;
If (num. equals (""))
{
Errortype = 1;
Response. sendRedirect ("enter. jsp? Errortype = "+ errortype );