JSP request对象详解
request是HttpServletRequest类的实例。客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。
方法
1. string getProtocol() //返回请求用的协议类型及版本号
request.getProtocol() 输出:HTTP/1.1
2. getServletConfig().getServletContext().getServerInfo() //服务器信息
输出:JavaServer Web Dev Kit/1.0 EA (JSP 1.0; Servlet 2.1; Java 1.2; Windows NT 5.0 x86; java.vendor=Sun Microsystems Inc.)
3. String getRemoteAddr() 返回发送此请求的客户端IP地址
request.getRemoteAddr() 输出:192.168.0.106
4. String getRemoteHost() 返回发送此请求的客户端主机名
5. String getCharacterEncoding() 返回字符编码方式
request.getCharacterEncoding()输出:GB2312
6. int getContentLength() 返回请求体的长度(以字节数)7. String getContentType() 得到请求体的MIME类型 8. string getAuthType() 获取Authorization头
request.getContentType()输出:basic或者digest
9. string getMethod() 获取请求类型
输出:通常是GET或