This is the 7th day of my participation in Gwen Challenge.More article challenges

demand

We often use a lot of procedures to register and log in our accounts and passwords in the daily process of surfing the Internet. This is an essential part of web development. This article will use Java+Tomcat to complete a simple account and password login web page.

function

First, you need to ask the user to enter his or her account number and password. After entering the user’s account and password, click login, and the verification will be automatically performed.

When the account and password correspond to the account and password saved in advance, the web page will display the user’s account name and prompt the correct one.

If the account password is incorrect, the web page displays a message indicating that the password is incorrect.

The program

This function is mainly realized through two pages, the first is a login page, which places the user to enter the account and password, and login jump procedures, that is, from. JSP behind us.

The other is the validation interface, which is the page.jsp file. The main function is to verify whether the password is correct or not and display the related page. The logical relationship among them is the focus of this procedure.

The login page

//from.jsp <%@ page language="java" contentType="text/html; <form action="page.jsp"> Please enter your account: <input name="account" type="text"><BR> Please enter your password: < form> </form> </body> </ HTML >Copy the code

Run to get the validation page, where action= “page.jsp”, representing the content entered in the form, is submitted to page.jsp to run.

Verify the page

//page.jsp <%@ page language="java" contentType="text/html; charset=UTF-8"%> <html> <body> <% String account=request.getParameter("account"); String password=request.getParameter("password"); String str3="wulianwangzhishi"; String str4="123456"; if(account! ="") {if(account.equals(str3) &&password.equals (str4)) {out.println(" password correct <br>"); Out. Println (" account: "+account +" <br>" ); } else out.print(" password error <br>"); } %> </body> </html>Copy the code

More wonderful

Internet of Things knowledge

Point a

Looking at the

You are the best

This article uses the article synchronization assistant to synchronize