实验2:
success:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>实验2</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1 style="green"> 登录成功! </h1>
<%
request.setCharacterEncoding("GBK");
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
%>
登录的用户名为: <%=name%><br>
登录的密码为: <%=pwd %><br>
<%! Integer yourNumber=new Integer(0); %>
<% if(session.isNew()){
Integer number=(Integer)application.getAttribute("Count");
if(number==null) {
number=new Integer(1);
}
else {
number=new Integer(number.intValue()+1);
}
application.setAttribute("Count", number);
yourNumber=(Integer)application.getAttribute("Count");
}%>
欢迎访问本站,您是第 <%=yourNumber %>个访问用户。
</center>
</body>
</html>
judge:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>实验2</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<h1>登陆</h1>
<%
request.setCharacterEncoding("gbk");
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
if(name!=null&&pwd!=null&&name.equals("123456")&&pwd.equals("111111")) {%>
<jsp:forward page = "success.jsp"/>
<%
}
else{
response.sendRedirect("fail.html");
} %>
</center>
</body>
</html>