zoukankan      html  css  js  c++  java
  • Jsp注册界面——request对象

    1. Reg.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>hello</title>
    </head>
    <body>
    <h1>用户注册</h1>
    <hr>

    <form action="RegSuccess.jsp" name="RegForm" method="post">
    <table>
    <tr>
    <td>用户名:</td>
    <td><input type="text" name="username"/></td>
    </tr>
    <tr>
    <td>密码:</td>
    <td><input type="password" name="password"/></td>
    </tr>
    <tr>
    <td>爱好:</td>
    <td><input type="checkbox" name="favorite" value="read">读书
    <input type="checkbox" name="favorite" value="run">跑步
    <input type="checkbox" name="favorite" value="listen">听歌
    <input type="checkbox" name="favorite" value="Wmovie">看电影
    </td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" value="提交"/></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    2.RegSuccess.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <h1>提交成功</h1>
    <%
    request.setCharacterEncoding("utf-8");
    request.setAttribute("gege", "123456");
    %>
    用户名:<%=request.getParameter("username")%>
    <br>
    密码: <%=request.getParameter("password") %>
    <br>
    爱好:<%
    String[] favorite=request.getParameterValues("favorite");
    for(int i=0;i<favorite.length;i++)
    {
    out.print(favorite[i]+"&nbsp;&nbsp");
    }
    %><br>
    hehe:<%=request.getAttribute("gege") %><br>
    得到请求体的MIME类型:<%=request.getContentType() %><br>
    返回请求的协议类型及版本号:<%=request.getProtocol() %><br>
    返回接收请求的服务器的主机名:<%=request.getServerName() %><br>
    返回接收请求的服务器的端口号:<%=request.getServerPort() %><br>
    返回请求体的长度:<%=request.getContentLength() %><br>
    返回客户端的IP地址:<%=request.getRemoteAddr() %><br>
    返回一虚拟路径的真实路径:<%=request.getRealPath("request.jsp") %><br>
    返回上下文路径:<%=request.getContextPath()%>
    </body>
    </html>

  • 相关阅读:
    python标准库学习-SimpleHTTPServer
    迁移cnblog博客
    zabbix监控使用
    20 个 OpenSSH 最佳安全实践
    编写基本的 udev 规则
    Linux.Siggen.180
    在 CentOS 7.0 上安装配置 Ceph 存储
    常用 GDB 命令中文速览
    Kubernetes TLS认证
    音乐下载api
  • 原文地址:https://www.cnblogs.com/youyumengyu/p/5509614.html
Copyright © 2011-2022 走看看