The structure of the user login module program is shown in Figure 1:
Users enter the password in the login page, verify the correct turn to the Welcome home page, if the password entered incorrectly, the login failed page. This module contains 6 JSP files, 3 Java classes, and two background tables.
Figure 1 Example page flow diagram
6 JSP files for user login, page flow control, error handling, login success and failure, as well as the Exit System processing page, briefly described as follows:
Table 1 JSP files
description |
login jsp page |
switch.jsp |
password verification and page flow control JSP pages. |
error.jsp |
error handling JSP page To report the program's errors in a friendly way to the customer. The error-handling page for all other JSP pages. |
welcome.jsp |
login succeeded to the Welcome page. We have referenced a set of Third-party tag libraries on this page. |
fail.jsp |
> Login failed, turn to this. Error-handling page. |
quit.jsp |
|
JSP files are mainly responsible for the presentation of the page, and business logic or resource processing functions can be placed in the Java class, the form data can be encapsulated by the bean, the module provides 3 classes, described below:
Table 2 3 Java classes
Class |
Description |
DbConnection |
Gets the connection to the database. |
User |
Describes user objects and is responsible for writing logins, exiting logs. |
UserList |
Gets all users of the system and converts to a Web page drop-down box. |
User information and user login information with a database table to store, select Oracle 9i as our database, of course, you can also use other types of databases, as long as the corresponding adjustment dbconnection class and table SQL definition statements can be, the cost of this transplant is very small, The purpose and structure of the two tables are described below:
Table 3 2 Database tables
Table name |
Description |
T_user |
User Information table containing 3 fields of user ID, username, and password. |
T_login_log |
Record the time of user login and the time of exit, the log primary key is generated by using a sequence seq_login_log_id. |
The two database tables and sequences are structured as follows:
Fig. 2 data table and sequence
The database username/password is: JBUSER/ABC. Before embarking on the development of our login module, you must first create a user in the database, create a build table, and a sequence.