<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("utf-8");
String uname=request.getParameter("uname");
String upwd=request.getParameter("upwd");
if("suzhe".equals(uname)&&("123".equals(upwd))){
session.setAttribute("uname", uname);
request.getRequestDispatcher("/tu.jsp").forward(request, response);
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form action="/jps1/one.jsp" method="post">
<input name="uname"/>
<input name="upwd" type="password"/>
<input type="submit" value="登錄"/>
<br/>
</form>
</body>
</html>
}else{response.sendRedirect("jps1/san.jps");}%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'login.jsp' starting page</title> </head> <body> 未滿十八歲請再家長的看護下觀看 <%=session.getAttribute("uname") %> <% //1.1 從作用域中取一道 Integer i=(Integer)application.getAttribute("count"); if(i!=null){ //有值 i=1+i; }else{ i=1; } application.setAttribute("count", i); %> 您是第 <%=i %>位訪客 <input type=""> </body> </html>