JBuilder2005 Practical JSP Program Function Introduction (6)
Author:Eve Cole
Update Time:2009-07-02 17:08:58
The structure diagram of the user login module program is shown below:
Figure 1 Example page flow chart |
The user enters the password on the login page and is directed to the main welcome page after verification is correct. If the entered password is incorrect, the user is directed to the login failure page. This module contains 6 JSP files, 3 Java classes and two background tables.
The six JSP files are user login, page flow control, error handling, login success and failure, and system exit processing pages. A brief introduction is as follows:
Table 1 JSP file
JSP page | description |
login.jsp | login JSP page |
switch.jsp | JSP page for password verification and page flow control. |
error.jsp | error handling JSP page reports program errors to customers in a friendly way. Error handling page for all other JSP pages. |
welcome.jsp | redirects to the welcome page after successful login. We reference a set of third-party tag libraries on this page. |
fail.jsp | redirects to this error handling page after login failure. |
quit.jsp | is a page called after exiting the system. It is responsible for clearing the session and ending the session. |
JSP files are mainly responsible for page display, while business logic or resource processing and other functions can be placed in Java classes, and form data can be encapsulated through Beans. The module provides 3 classes, which are introduced as follows:
Table 2 3 Java classes
Class | Description |
DBConnection | Gets the connection to the database. |
User | describes the user object and is responsible for writing login and logout logs. |
UserList | obtains all users of the system and converts it into a web page drop-down box. |
User information and user login information are stored in database tables. Oracle 9i is selected as our database. Of course, you can also use other types of databases. Just adjust the DBConnection class and table SQL definition statements accordingly. This kind of transplantation The price is very small. The purpose and structure of these two tables are introduced below:
Table 3 2 database tables
Table name | description |
T_USER | user information table, including three fields: user ID, user name and password. |
T_LOGIN_LOG | records the user login time and logout time. The log primary key is generated using a sequence SEQ_LOGIN_LOG_ID. |
The structures of these two database tables and sequences are as follows:
Figure 2 Data table and sequence |
The database username/password is: jbuser/abc. Before we start developing our login module, we must first create users in the database and create generated tables and sequences.