Case Description: When the user has not logged in to access the Welcome screen, the page jumps to the login screen, and displays the prompt message;
If the user fill in the information is inconsistent with the fixed user information, the login screen display error message, otherwise jump to the Welcome page, display the user name information.
New Login2.java-User login interface, when the user information input error, will display a reminder message. (When the user directly accesses the Welcome interface, if the user's session does not exist, then jump to the login screen to remind users not to log in)
Servlet Deployment for Login2.java
New Logincl2.java-The user input information to verify, if the user information is correct, add the session and its properties, if necessary, set the time of the session, and jump to the welcome interface; If the user fills in the wrong information, the login screen displays an error alert.
Servlet Deployment for Logincl2.java
New Wel2.java-Welcome interface (detects whether a session of a property exists, if not empty is present, the welcome message is displayed, otherwise jump to the login screen and display the Error alert message)
servlet deployment for Wel2.java
turn on Tomcat, Access 127.0.0.1:8080/myweb-site/wel2 on your browser, page display jumps to login screen and displays error alerts , as follows:
Fill in the user information (the user name and password are incorrect), the page effect is as follows: (User name or password error effect self-operation)
Enter the correct user information, jump to the Welcome screen, the effect is as follows:
If you refresh the page again within 20s of the session, the page will be the same, and if you refresh the page after 20s, the page effect is as follows:
Simple User Login website (HttpServlet1.2 version)