There are three files in this dbhelper test.
One is dbhelper Java file, because of too much code is not described.
The other two are JSP files, one for the index.jsp code for the login page
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title> Login Page </title>
<body>
<form name= "F1" action= "login.jsp" >
User name: <input type= "text" name= "UID" ><br>
Password: <input type= "password" name= "pwd" ><br>
<input type= "Submit" value= "Login" >
</form>
</body>
The second is the login.jsp code for the validation page
<% @page import= "Java.sql.ResultSet"%>
<%@ page language= "java" import= "java.util.*,dbhelper.*"
pageencoding= "UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>my JSP ' login.jsp ' starting page</title>
<body>
<%
String sql= "SELECT * from user where username=? and password=? ";
String uid=request.getparameter ("UID");
String pwd=request.getparameter ("pwd");
Object[] Params=new object[]{uid,pwd};
ResultSet rs= Dbhelper.getresultset (SQL, params);
if (Rs.next ())
Out.print ("Landing success");
Else
Out.print ("Login Failed");
Rs.close ();
%>
</body>
According to two code connection database to authenticate the user name password, there are many noteworthy in the code writing, because the novice writing may have a lot of errors, and in the teacher's hands-on teaching still a little bit of error such as: Bad environment configuration is incorrect, code is not written correctly I think in the course of learning Web project design and development should not only consolidate the previous Web page design knowledge, but also to self-study, to learn good computer language for the purpose, later engaged in the computer industry is proud.
Web project design and development —————— DBHelper testing