This section covers two pages, one donewuser.jsp file is used to implement record add operations, another file listuser.jsp file
Used to display all of the registered user information. Both of these pages involve a specific call to the JavaBean, or look at the file,
Comments are added to the key code in the file for easy understanding.
donewuser.jsp file
Description: The user registers the Operation page, and according to the user registration success whether displays the corresponding feedback information, this page main characteristic is uses the
Lyf.adduser this JavaBean addnewuser () method to add records.
<%@ page contenttype= "text/html;charset=gb2312"%>
<% Response.setheader ("Expires", "0"); %>
<!--generates an JavaBean:lyf.adduser instance with ID AddUser, page--> Survival Range
< Jsp:usebean id= "AddUser" class= "Lyf.adduser" scope= "page"/>
<!--set the values of each property in the JavaBean, which calls the set method of each property in JavaBean so that JavaBean gets
The correct property value, "*" represents a match for all properties-->
< Jsp:setproperty name= "AddUser" property= "*"/>
< html>
< head>
< meta http-equiv= "Content-language" content= "ZH-CN" >
< meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
< meta name= "generator" content= "Microsoft FrontPage 3.0" >
< meta name= "ProgId" content= "FrontPage.Editor.Document" >
< title> user Add </title>
< body bgcolor= "#FFEBBD" >
< div align= "center" >< center>
<%
Call the Lyf.adduser checkuser () method to check for duplicate user names
Display the corresponding information if there are duplicates
if (!adduser.checkuser ())
{
Page text output information, using the JSP built-in object out of the Println method, equivalent to the ASP Response.Write method
Out.println ("Sorry, this username" +adduser.getusername () + "has been applied, please choose again!" ");
Return representative returns, run the time to hit back will not do the following processing, function equivalent to Response.End in ASP
Return
}
%>
<%
If there is no problem with user name duplication, call the Lyf.adduser Addnewuser () method to add user data to the database and
Display the corresponding information based on whether the data was added successfully
if (Adduser.addnewuser ()) {
%>
< h2> Add User success!
< h2> add user failed, please contact admin!
</body>
listuser.jsp file
Description: User Information list page, used to display all the registered user information, the data is paginated.
For the convenience of everyone, using a common paging code, if it is JDBC2.0 above or other support
The database driver for the type_scroll_insensitive cursor can have a more concise paging method.
And the previous JSP page similar to the statement is not explained, the representative
This page to import Java.sql.ResultSet class library, because the JSP page in the middle to declare resultset;
The Oracle.jdbc.driver.* class Library is an Oracle-specific JDBC driver that allows JSP pages to be used for Oracle database operations.
<%@ page contenttype= "text/html;charset=gb2312"%>
<% Response.setheader ("Expires", "0"); %>
<%@ page import= "Java.sql.ResultSet"%>
<%@ page import= "oracle.jdbc.driver.*"%>
<!--generate a JavaBean:lyf.db instance-->
< Jsp:usebean id= "db" class= "lyf.db" scope= "Request"/>
< Jsp:setproperty name= "db" property= "*"/>
<%