request对象

客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。它是HttpServletRequest类的实例。

序号 方 法 说 明 
1  object getAttribute(String name) 返回指定属性的属性值 
2  Enumeration getAttributeNames() 返回所有可用属性名的枚举 
3  String getCharacterEncoding() 返回字符编码方式 
4  int getContentLength() 返回请求体的长度(以字节数) 
5  String getContentType() 得到请求体的MIME类型 
6  ServletInputStream getInputStream() 得到请求体中一行的二进制流 
7  String getParameter(String name) 返回name指定参数的参数值 
8  Enumeration getParameterNames() 返回可用参数名的枚举 
9  String[] getParameterValues(String name) 返回包含参数name的所有值的数组 
10  String getProtocol() 返回请求用的协议类型及版本号 
11  String getScheme() 返回请求用的计划名,如:http.https及ftp等 
12  String getServerName() 返回接受请求的服务器主机名 
13  int getServerPort() 返回服务器接受此请求所用的端口号 
14  BufferedReader getReader() 返回解码过了的请求体 
15  String getRemoteAddr() 返回发送此请求的客户端IP地址 
16  String getRemoteHost() 返回发送此请求的客户端主机名 
17  void setAttribute(String key,Object obj) 设置属性的属性值 
18  String getRealPath(String path) 返回一虚拟路径的真实路径 
19     
20

<%@ page contentType="text/html;charset=gb2312"%>
<%request.setCharacterEncoding("gb2312");%>
<html>
<head>
<title>request a00-206 </title>
</head>
<body bgcolor="#FFFFF0">
<form action="" method="post">
  <input type="text" name="qwe">
  <input type="submit" value="提交">
</form>
请求方式:<%=request.getMethod()%><br>
请求的资源:<%=request.getRequestURI()%><br>
请求用的协议:<%=request.getProtocol()%><br>
请求的文件名:<%=request.getServletPath()%><br>
请求的服务器的IP:<%=request.getServerName()%><br>
请求服务器的端口:<%=request.getServerPort()%><br>
客户端IP地址:<%=request.getRemoteAddr()%><br>
客户端主机名:<%=request.getRemoteHost()%><br>
表单提交来的值:<%=request.getParameter("qwe")%><br>
</body>
</html> 
<%@ page contentType="text/html;charset=gb2312"%>
<%request.setCharacterEncoding("gb2312");%>
<%@ page import="java.util.Enumeration"%>
<html>
<head>
  <title>request 250-10 </title>
</head>
<body bgcolor="#FFFFF0">
<form action="" method="post">
   用户名:<input type="text" name="username">&nbsp;&nbsp;
   密 码:<input type="text" name="userpass">&nbsp;&nbsp;
   <input type="submit" value="进入" >
</form>
<%
String str="";
if(request.getParameter("username")!=null && request.getParameter("userpass")!=null){
   Enumeration enumt = request.getParameterNames();
   while(enumt.hasMoreElements()){
      str=enumt.nextElement().toString();
      out.println(str+":"+request.getParameter(str)+"<br>");
   }
}
%>
</body>
</html> 
<%@ page contentType="text/html;charset=gb2312"%>
<%request.setCharacterEncoding("gb2312");%>
<html>
<head>
   <title> e20-090 </title>
</head>
<body bgcolor="#FFFFF0">
<form action="" method="post">
  擅长:<input type="checkbox" name="cb" value="ON1">VC++&nbsp;
       <input type="checkbox" name="cb" value="ON2">JAVA&nbsp;
       <input type="checkbox" name="cb" value="ON3">DELPHI&nbsp;
       <input type="checkbox" name="cb" value="ON4">VB&nbsp;
       <br>
       <input type="submit" value="进入" name="qwe">
</form>
<%
if(request.getParameter("qwe")!=null ){
   for(int i=0;i<request.getParameterValues("cb").length;i++){
      out.println("cb"+i+":"+request.getParameterValues("cb")[i]+"<br>");
   }
   out.println(request.getParameter("qwe"));
}
%>
</body>
</html>

jsp 详解request对象的更多相关文章

  1. Struts功能详解——ActionMapping对象

    Struts功能详解——ActionMapping对象 ActionMapping描述了struts中用户请求路径和Action的映射关系,在struts中每个ActionMapping都是通过pat ...

  2. dom对象详解--document对象(二)

       dom对象详解--style对象 style对象 style对象和document对象下的集合对象styleSheets有关系,styleSheets是文档中所有style对象的集合,这里讲解的 ...

  3. dom对象详解--document对象(一)

     document对象 Document对象代表整个html文档,可用来访问页面中的所有元素,是最复杂的一个dom对象,可以说是学习好dom编程的关键所在. Document对象是window对象的一 ...

  4. js对象详解(JavaScript对象深度剖析,深度理解js对象)

    js对象详解(JavaScript对象深度剖析,深度理解js对象) 这算是酝酿很久的一篇文章了. JavaScript作为一个基于对象(没有类的概念)的语言,从入门到精通到放弃一直会被对象这个问题围绕 ...

  5. php开发面试题---php面向对象详解(对象的主要三个特性)

    php开发面试题---php面向对象详解(对象的主要三个特性) 一.总结 一句话总结: 对象的行为:可以对 对象施加那些操作,开灯,关灯就是行为. 对象的形态:当施加那些方法是对象如何响应,颜色,尺寸 ...

  6. Java Web(五) JSP详解(四大作用域九大内置对象等)

    前面讲解了Servlet,了解了Servlet的继承结构,生命周期等,并且在其中的ServletConfig和ServletContext对象有了一些比较详细的了解,但是我们会发现在Servlet中编 ...

  7. 【转载】JSP详解(四大作用域九大内置对象等)

    前面讲解了Servlet,了解了Servlet的继承结构,生命周期等,并且在其中的ServletConfig和ServletContext对象有了一些比较详细的了解,但是我们会发现在Servlet中编 ...

  8. web开发(五) JSP详解(四大作用域九大内置对象等)

    在网上看见一篇不错的文章,写的详细. 以下内容引用那篇博文.转载于<http://www.cnblogs.com/whgk/p/6427759.html>,在此仅供学习参考之用. 一.JS ...

  9. jsp详解(3个指令、6个动作、9个内置对象、11个隐式对象)

    jsp概述SP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术.JSP实际上就是Servlet.    jsp=html+jav ...

随机推荐

  1. access处理重复创建表的方法。

    第一种,使用MSysObjects表查找表名为当前创建表的名字的内容,相当于普通查询,但是access数据库有一个安全问题,就是有时候一开始是没有权限去调这些系统表的,这时可以再2007的access ...

  2. 如何启动Intel VT-x

    如何启动Intel VT-x 5 在64bit win7系统下安装了Vmware10,然后安装64位的UbuntuKylin 14.04,想要打开UbuntuKylin,弹出如下对话框: 请问该如何启 ...

  3. 部署Geoserver tomcat部署geoserver

    1. 下载Geoserver War 包. 2.把geoserver.war文件放到 webapps文件夹下 3.添加Tomcat 用户 解压文件conf文件夹下 修改tomcat-users.xml ...

  4. Ace 在Vue中使用方法

    var Vue = require('vue/dist/vue.common.js'); document.querySelector('body').append(document.createEl ...

  5. 企业版https

    http://www.cocoachina.com/bbs/read.php?tid=194213

  6. 学习C语言库函数

    使用C语言功能强大的函数,我们需要包含头文件 #include<math.h>. 1)取两个数的较大值或较小值函数: double a = 9.9; double b = 6.6; pri ...

  7. jquery 获取tbody下的第二个tr 及多级标签

    <div id="testSlider"> <div class="esriTimeSlider ies-Slider" id="t ...

  8. MySQL 查询优化之 Index Condition Pushdown

    MySQL 查询优化之 Index Condition Pushdown Index Condition Pushdown限制条件 Index Condition Pushdown工作原理 ICP的开 ...

  9. Centos7.2 上部署 FastDFS_V5.05

    1.安装gcc (编译时需要) [root@localhost~]# yum -y install gcc gcc-c++ 2.安装libevent ,FastDFS依赖libevent库; [roo ...

  10. 【linux】【网络安全】linux中怎样关闭ICMP回应功能

    引用自:http://blog.csdn.net/qq844352155/article/details/49700121       linux中怎样关闭ICMP回应功能   输入:   echo ...