JSP编程中常用的获取HTTP信息头的方法

介绍一些在JSP编程中常用的获取HTTP信息头的方法。详细内容请见下表:

1 Cookie[] getCookies()
返回客户端所有的Cookie的数组
2 Enumeration getAttributeNames()
返回request对象的所有属性名称的集合
3 Enumeration getHeaderNames()
返回所有HTTP头的名称集合
4 Enumeration getParameterNames()
返回请求中所有参数的集合
5 HttpSession getSession()
返回request对应的session对象,如果没有,则创建一个
6 HttpSession getSession(boolean create)
返回request对应的session对象,如果没有并且参数create为true,则返回一个新的session对象
7 Locale getLocale()
返回当前页的Locale对象,可以在response中设置
8 Object getAttribute(String name)
返回名称为name的属性值,如果不存在则返回null。
9 ServletInputStream getInputStream()
返回请求的输入流
10 String getAuthType()
返回认证方案的名称,用来保护servlet,比如 “BASIC” 或者 “SSL” 或 null 如果 JSP没设置保护措施
11 String getCharacterEncoding()
返回request的字符编码集名称
12 String getContentType()
返回request主体的MIME类型,若未知则返回null
13 String getContextPath()
返回request URI中指明的上下文路径
14 String getHeader(String name)
返回name指定的信息头
15 String getMethod()
返回此request中的HTTP方法,比如 GET,,POST,或PUT
16 String getParameter(String name)
返回此request中name指定的参数,若不存在则返回null
17 String getPathInfo()
返回任何额外的与此request URL相关的路径
18 String getProtocol()
返回此request所使用的协议名和版本
19 String getQueryString()
返回此 request URL包含的查询字符串
20 String getRemoteAddr()
返回客户端的IP地址
21 String getRemoteHost()
返回客户端的完整名称
22 String getRemoteUser()
返回客户端通过登录认证的用户,若用户未认证则返回null
23 String getRequestURI()
返回request的URI
24 String getRequestedSessionId()
返回request指定的session ID
25 String getServletPath()
返回所请求的servlet路径
26 String[] getParameterValues(String name)
返回指定名称的参数的所有值,若不存在则返回null
27 boolean isSecure()
返回request是否使用了加密通道,比如HTTPS
28 int getContentLength()
返回request主体所包含的字节数,若未知的返回-1
29 int getIntHeader(String name)
返回指定名称的request信息头的值
30 int getServerPort()
返回服务器端口号

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值