• 4-16 表单提交信息和获取。


    login.jsp

    <%@ 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>
        <base href="<%=basePath%>">
        
        <title>My JSP 'login.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
      </head>
      
      <body>
      <form id="form1" name="form1" method="post" action="login_deal.jsp">
      用户名:<br>
      <input name="username" type="text" id="username"/>
      <br>
      密码:<br>
      <input name="pwd" type="password" id="pwd" />
      <br>
      <input type="submit" name="Submit" value="提交" />
      <input type="reset" name="Submit2" value="重置" />
      </form>
      </body>
    <ml>

    login_deal:

    <%@ 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>
        <base href="<%=basePath%>">
        
        <title>My JSP 'login_deal.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
      </head>
      
      <body>
        <%
          String username=request.getParameter("username");
           String pwd=request.getParameter("pwd");
           if(username.equals("abcd")&&pwd.equals("1234"))
                  response.sendRedirect("login_ok.jsp");
            else
                   response.sendError(500,"用户名或密码不正确");
         %>
      </body>
    <ml>

    login_ok:

    <%@ 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>
        <base href="<%=basePath%>">
        
        <title>My JSP 'login_ok.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
    
      </head>
      
      <body>
        登录成功。 <br>
      </body>
    <ml>
  • 相关阅读:
    怎样才是全能的程序员?
    [HDU 2553]N皇后问题
    [HDU 1870]愚人节的礼物
    [HDU 1016]Prime Ring Problem
    [HDU 1241]Oil Deposits
    [POJ 3250]Bad Hair Day
    [HDU 1276]士兵队列训练问题
    [POJ 2796]Feel Good
    [HDU 1237] 简单计算器
    总算开通博客园啦~
  • 原文地址:https://www.cnblogs.com/cancangood/p/4433030.html
Copyright © 2020-2023  润新知