<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>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>JSP简单登录实例</title>
</head>
<body>
<h2>请登录</h2>
<form method="POST" >
Login Name: <input type="text" name="Name"><br>
Login Password: <input type="text" name="Password" ><br>
<input type="submit" value="Send"><br>
<form>
<%
if (request.getParameter("Name") != null
&& request.getParameter("Password") != null) {
String Name = request.getParameter("Name");
String Password = request.getParameter("Password");
if (Name.equals("a") && Password.equals("a")) {
session.setAttribute("Login", "OK");
session.setAttribute("myCount", new Integer(1));
response.sendRedirect("welcome.jsp");
}
else {
%>
登录失败:用户名或密码不正确~
<%
}
}
%>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<%
session.setAttribute("Login", "");
%>
<body>
<h2>你已经退出登录</h2>
</body>
</html>
<%@ page contentType="text/html" pageEncoding="UTF-8" import="java.util.*"%>
<html>
<body>
<h2>欢迎页面(测试session)</h2>
<%
String Login = (String)session.getAttribute("Login");
int nCount=0;
if (Login != null && Login.equals("OK")) {
Integer myCount = (Integer)session.getAttribute("myCount");
if(myCount!=null)
{
nCount = myCount.intValue();
nCount = nCount + 1;
session.setAttribute("myCount",new Integer(nCount));
}
%>
登录成功,myCount=<%=nCount%></br>
<input type=button value="退出" onclick="javascript:location.href='logout.jsp'">
<%
}
else {
%>
<jsp:forward page="login.jsp"/>
<%
}
%>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有