学习笔记.docx
- 文档编号:26318925
- 上传时间:2023-06-17
- 格式:DOCX
- 页数:17
- 大小:37.09KB
学习笔记.docx
《学习笔记.docx》由会员分享,可在线阅读,更多相关《学习笔记.docx(17页珍藏版)》请在冰豆网上搜索。
学习笔记
jsp内置对象及其方法
1.request对象
客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。
它是HttpServletRequest类的实例。
序号方法说明
1 objectgetAttribute(Stringname)返回指定属性的属性值
2 EnumerationgetAttributeNames()返回所有可用属性名的枚举
3 StringgetCharacterEncoding()返回字符编码方式
4 intgetContentLength()返回请求体的长度(以字节数)
5 StringgetContentType()得到请求体的MIME类型
6 ServletInputStreamgetInputStream()得到请求体中一行的二进制流
7 StringgetParameter(Stringname)返回name指定参数的参数值
8 EnumerationgetParameterNames()返回可用参数名的枚举
9 String[]getParameterValues(Stringname)返回包含参数name的所有值的数组
10 StringgetProtocol()返回请求用的协议类型及版本号
11 StringgetScheme()返回请求用的计划名,如:
http.https及ftp等
12 StringgetServerName()返回接受请求的服务器主机名
13 intgetServerPort()返回服务器接受此请求所用的端口号
14 BufferedReadergetReader()返回解码过了的请求体
15 StringgetRemoteAddr()返回发送此请求的客户端IP地址
16 StringgetRemoteHost()返回发送此请求的客户端主机名
17 voidsetAttribute(Stringkey,Objectobj)设置属性的属性值
18 StringgetRealPath(Stringpath)返回一虚拟路径的真实路径
<%@pagecontentType="text/html;charset=gb2312"%>
<%request.setCharacterEncoding("gb2312");%>
请求方式:
<%=request.getMethod()%>
请求的资源:
<%=request.getRequestURI()%>
请求用的协议:
<%=request.getProtocol()%>
请求的文件名:
<%=request.getServletPath()%>
请求的服务器的IP:
<%=request.getServerName()%>
请求服务器的端口:
<%=request.getServerPort()%>
客户端IP地址:
<%=request.getRemoteAddr()%>
客户端主机名:
<%=request.getRemoteHost()%>
表单提交来的值:
<%=request.getParameter("qwe")%>