<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>login</title> </head> <body> <form action="./dologin.jsp" method="post" > 用户名:<input name="userName"/><br><br> 密码: <input name="passWord"/><br><br> <input type="submit" value="登陆"/><br><br> </form> </body>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <html> <head> <title>My JSP ‘success.jsp‘ starting page</title> </head> <body> 欢迎你!<%=request.getParameter("userName") %> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String username=request.getParameter("userName"); String password=request.getParameter("passWord"); if(username.equals("tom")&&password.equals("123")) { //跳转到成功页面 request.getRequestDispatcher("success.jsp").forward(request, response); } else{ //返回登陆页面重新登陆 response.sendRedirect("logion.jsp"); } %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String username=request.getParameter("userName");
String password=request.getParameter("passWord");
if(username.equals("tom")&&password.equals("123"))
{
//跳转到成功页面
request.getRequestDispatcher("success.jsp").forward(request, response);
}
else{
//返回登陆页面重新登陆
response.sendRedirect("logion.jsp");
}
%>