zoukankan      html  css  js  c++  java
  • request内置对象

    <%@ page language="java" import="java.util.*" contentType="text/html; charset=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>Request内置对象</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>
    <%
    request.setAttribute("password", "123456");
    request.setCharacterEncoding("utf-8");//设置接受表单时的请求接受默认编码字符集为utf-8,与发出请求的字码集相同
    %>
    <h2>request内置对象</h2>
    用户名:<%=request.getParameter("username") %><br>
    密码:<%=request.getAttribute("password") %><br> <!-- getAttriybute只能得到setAttribute对应的参数 -->
    爱好:<%
    if(request.getParameterValues("favorite")!=null){
    String[] favorite = request.getParameterValues("favorite");
    for(int i=0;i<favorite.length;i++) //一开始想该数组数据的值若为空,则.length为0,然而并不是
    out.println(favorite[i]+"&nbsp;&nbsp;");
    }
    %>
    请求体的MIME类型:<%=request.getContentType() %><br>
    协议类型及版本号:<%=request.getProtocol() %><br>
    服务器主机名:<%=request.getServerName() %><br>
    服务器端口号:<%=request.getServerPort() %><br>
    文件的单位长度:<%=request.getContentLength() %>byte<br>
    请求客户端的IP地址:<%=request.getRemoteAddr() %><br>
    请求的真是物理路径:<%=request.getRealPath("Request.jsp") %><br>
    请求的上下文路径:<%=request.getContextPath() %><br>
    </body>
    </html>

  • 相关阅读:
    关于阿里云centos 2.6下手机表情输入后无法保存到mysql数据库的问题调研及mysql版本从5.1升级到5.7的全过程纪要
    EXTJS 5 学习笔记2
    EXTJS 5 学习笔记1
    关于java.lang.String理解中的一些难点
    关于centos7中使用rpm方式安装mysql5.7版本后无法使用root登录的问题
    大数据专栏
    过采样中用到的SMOTE算法
    linux后台执行命令:&和nohup
    P,R,F1 等性能度量(二分类、多分类)
    word2vec模型cbow与skip-gram的比较
  • 原文地址:https://www.cnblogs.com/wkt-gut/p/7594308.html
Copyright © 2011-2022 走看看