Login verification and logging

Disclaimer: The materials used in this column are written by VIP students of Kaige Academy. Students have the right to remain anonymous and have the right to final interpretation of the article. Kaige Academy aims to promote VIP students to learn from each other based on public notes.

Login verification and logging

I have previously introduced how to write a simple login verification using knowledge points such as Server, mysql, and tomcat. But now there is a new requirement, I want to record a log to the database when the login is successful, and also record when the login fails. This log records the username, the user's IP address, the time of the login, and the status flag of success or failure.
So now you need to add a table to store log information, as shown in the figure:

image

Because most of the ideas are similar to the previous log-in verification, but there is an additional log, so I will not repeat the implementation ideas here, and go directly to the code.
1. First, you need to use html to write a page, code example:

image

image

CSS code:

image

image

image

image

  1. The same need to write a class to manage the database pool:

image

image

  1. The servlet class that receives and processes the response to the user's request:

image

image

  1. Finally, the class that does the interacting with the database:

image

image

image

Finished effect:

image

After successful login, jump to the target page:

image

Login failed:

image

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326561334&siteId=291194637