Simple login example implemented by pure JSP and jsp login example
This article describes the simple login method implemented by pure JSP. We will share this with you for your reference. The details are as follows:
There are four files: web. xml, login. jsp, logout. jsp, and welcome. jsp.
Test environment: Tomcat 6.0.x
Assume that the project name is LoginSample, and my directory structure is as follows:
... \ Webapps \ LoginSample \ WEB-INF \ web. xml
... \ Webapps \ LoginSample \ login. jsp
... \ Webapps \ LoginSample \ logout. jsp
... \ Webapps \ LoginSample \ welcome. jsp
Web. xml source code list:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"version="2.4"> <welcome-file-list> <welcome-file>welcome.jsp</welcome-file> </welcome-file-list></web-app>
Login. jsp Source Code List:
<% @ Page contentType = "text/html; charset = UTF-8 "%>
Logout. jsp Source Code List:
<% @ Page contentType = "text/html; charset = UTF-8" %>
Welcome. jsp Source Code List:
<% @ Page contentType = "text/html" pageEncoding = "UTF-8" import = "java. util. * "%>
I hope this article will help you with JSP program design.