Implementation of JSP login verification

Source: Internet
Author: User

The static interface design is login.htm. The Code is as follows:

<Html>
<Head>
<Title> system logon </title>
<Style type = "text/css">...
<! --
. Style1 {...}{
Font-size: 18px;
Font-weight: bold;
}
. Style2 {...} {font-size: 24px}
. Style5 {...} {font-size: 16px}
-->
</Style>
</Head>
<Body bgcolor = "papayawhip" width = "300" height = "300">
<Center>
<Table border = "2" bordercolor = "black" bgcolor = "lightgreen">
<Tbody>
<Tr>
<Td> <div align = "center" class = "style1 style2"> system Logon
</Div> </td>
</Tr>
<Form action = "login. jsp (preferred for SUN Enterprise Applications)" method = "post">
<Tr>
<Td height = "28"> <span class = "style5"> User name </span> <input type = "text" name = "uid" maxlength = "20" style = "width: 150 "> </td> </tr> <br>
<Tr>
<Td> <span class = "style5"> password & nbsp; code </span> <input type = "password" name = "upwd" maxlength = "20" style = "width: 150 "> </td> </tr> <br>
<Center>
<Tr> <td> <div align = "center">
<Input type = "submit" value = "login"> & nbsp;
<Input type = "reset" value = "cancel">
</Div> </td> </tr>
</Center>
</Form>

</Tbody>
</Table>
</Center>
</Body>
</Html>
Submit the information entered by the login user to login. jsp (preferred for SUN Enterprise Applications) page model processing. For convenience, you can directly use sky2098 as the login username and password without performing database access operations, but in practice, it is to read from the database. The jsp (preferred for SUN Enterprise Applications) Page code implementation is as follows:

<%... @ Page contentType = "text/html; charset = GB2312" %>
<%...
If (request. getParameter ("uid"). equals ("sky2098") & request. getParameter ("upwd"). equals ("sky2098 ")){
Session. setAttribute ("login", "OK ");
Session. setMaxInactiveInterval (-1 );
%>
<Jsp (preferred for SUN Enterprise Applications): forward page = "main. jsp (preferred for SUN Enterprise Applications)"/>
<%...
} Else {
Out. println ("incorrect user name or password! ");
}
%>

If the logon is successful, set the login value to OK and submit it to the next verification page to go to main. jsp (preferred for SUN Enterprise Applications) page. Otherwise, if the entered user name and password are invalid, the error message is printed. main. the jsp (preferred for SUN Enterprise Applications) Page code is as follows:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.