Joke Collection Website - Public benefit messages - How to implement jsp verification code?

How to implement jsp verification code?

1 The server randomly generates a string and saves it in the cache (session).

2 The server automatically generates a picture using a program and stores the randomly generated string. Write on the picture,

3 Send the picture to the browser

4 The viewer writes the text seen on the picture into the text box,

5 When the form is submitted, the text is sent to the server.

6 The server verifies whether the text sent is consistent with the string stored in the cache (session). If so, it passes the verification, otherwise it is illegal. Operation