The following figure shows the structure of the user login Module program:
Figure 1 instance page flow chart
The user enters the correct password on the logon page and turns to the welcome homepage. If the entered password is incorrect, go to the logon failure page. This module contains 6 JSP files, 3 Java classes, and two background tables.
The six JSP files are respectively user logon, page flow control, error handling, logon success and failure, and the processing page for exiting the system. The following is a brief introduction:
Table 1 JSP file
JSP page
Description
Login. jsp
Log on to the JSP page
Switch. jsp
The JSP page for password verification and page flow control.
Error. jsp
The error handling JSP page reports program errors to the customer in a friendly way. The error handling page for all other JSP pages.
Welcome. jsp
The welcome page that is displayed after successful logon. We reference a third-party tag library on this page.
Fail. jsp
If logon fails, go to the error handling page.
Quit. jsp
The page called after exiting the system. It clears the session and ends the session.
JSP files are mainly responsible for page display, while business logic or resource processing functions can be placed in Java classes, form data can be encapsulated by Bean, and three classes are provided in the module, introduction:
Table 2 3 Java classes
Class
Description
DBConnection
Obtain the database connection.
User
Describes user objects and is responsible for writing logon and exit logs.
UserList
Obtain all users of the system and convert them to a webpage drop-down list.
User information and user login information are stored in the database table. Select Oracle 9i as our database. Of course, you can also use other types of databases, you only need to adjust the DBConnection class and the SQL definition statement of the table accordingly. The porting cost is very small. The purpose and structure of the two tables are described below:
Table 3 2 database tables
Table name
Description
T_USER
The user information table contains three fields: User ID, user name, and password.
T_LOGIN_LOG
Logs the logon time and exit time. The log primary key is generated using a sequence of SEQ_LOGIN_LOG_ID.
The structure of these two database tables and sequences is as follows:
Figure 2 data table and sequence
The database username/password is jbuser/abc. Before developing our login module, you must create a user in the database to create a table and sequence.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.