1. This is a JSP instance, consisting of four JSP pages, handles users' registration and login information
2. The first is login.jsp, the code is as follows:
Username
Password
form>
center>
html>
3. Test.jsp code is as follows: (Mainly handled user registration, insert registration information into the database)
<% @ page language = "java" import = "java.sql. *"%>
Your username is: <% = request.getParameter ("UserName")%>
Your Password Is: <% = Request.getParameter ("pass")%>
<%
String name = Request.getParameter ("UserName");
String Pass = Request.getParameter ("pass");
Try
{
Class.Forname ("Sun.jdbc.odbc.jdbcodbcdriver");
Connection dbcon = drivermanager.getConnection ("JDBC: ODBC: TEST", "SA", "");
PreparedStatement stat = dbcon.preparestatement
"Insert Login Values (?,?)");
Stat.setString (1, name);
Stat.SetString (2, pass);
Stat.executeUpdate ();
out.println ( " insert successful B>");
}
Catch (Exception E)
Out.println (e);
%>
Click Here to View All People b>
4. Test2.jsp, the code is as follows: (Processing You can view all registered user list after the user is successfully registered)
<% TRY
"SELECT * from login");
ResultSet Result = stat.executeQuery ();
While (result.next ())
TABLE>
5. Test3.jsp code is as follows: (handle user login information)
"SELECT * from login where username =? and password =?");
Stat.setString (2, pass); ResultSet Result = stat.executeQuery ();
IF (result.next ())
Out.println ("Login Successful");
Else
Out.println ("Login Error");
6. Also need a database named login, only two columns Username, Password can
First registration, username 33, password 33
registration success
View registered users
Landed successfully