第四次jsp作业(2)

<%@ 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="text3.jsp" method="post">
        <table>
            <tr>
                <td>用户名:</td>
                <td><input type="text" name="user"></td>
            </tr>        
                
                <tr>
                    <td>用户名由字母或数字组成</td>
                </tr>
            
            <tr>
                <td>密码:</td>
                <td><input type="text" name="password"></td>
            </tr>
                
                <tr>
                    <td>密码由字母、数字和下划线组成。至少4位</td>
                </tr>
                
                <tr>
                    <td><input type="submit" value="登陆"></td>
                </tr>
        </table>
    </form>
  </body>
</html>
<%@ 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>
  <%
      request.setCharacterEncoding("utf-8");
      String user=request.getParameter("user");
      String password=request.getParameter("password");
       %>
       <%if(user.equals("lucky")&& password.equals("123456")){ %>
       <h2>你好,lucky</h2>
      <%}else{%>
      <%
      request.getRequestDispatcher("text2.jsp").forward(request,
                response);
       %>
  <%} %>
  </body>
</html>

猜你喜欢

转载自www.cnblogs.com/guoyang8260/p/12593516.html