request常用的方法

 request方法综合:--

返回请求方式:-request.getMethod()-----GET
返回URI中的资源名称(位于URL中端口后的资源路径):-request.getRequestURI()-----/myservlet/RequestMethodColligate.html
返回URL中的参数部分:-request.getQueryString()-----null
返回URL中的协议名:-request.getProtocol()-----HTTP/1.1
返回所属于的路径WEB站点:-request.getContextPath()-----/myservlet
返回额外信息路径:-request.getPathInfo()-----null
返回额外信息所对应的资源的真实路径:-request.getPathTranslated()-----null
返回SERVLET所映射的路径在XML文档中设置:-request.getServletPath()-----/RequestMethodColligate.html


-----------------------------------------------


以下为获取网络连接信息,在ServletRequest接口的方法综合实例:------


------获取客户机上的有:---
获取客户机的IP地址:--request.getRemoteAddr()-------127.0.0.1
获取客户机的主机名:--request.getRemoteHost()-------127.0.0.1
获取客户机的端口号:--request.getRemotePort()-------1373
获取客户机发出请求时的完整URL:--request.getRequestURL()-------http://localhost:8080/myservlet/RequestMethodColligate.html


------以下为获取本地服务器中的网络信息有:-----


服务器接收当前的网络接口的IP地址:--request.getLocalAddr()-------127.0.0.1
所对应的主机名:--request.getLocalName()-------localhost
对应的端口号:--request.getLocalPort()-------8080
获取当前请求所指向的主机名:--request.getServerName()-------localhost
获取当前请求的所连接的服务器端口号:--request.getServerPort()-------8080
获取请求的协议名:--request.getScheme()-------http

posted @ 2017-11-23 11:33  haw2106  阅读(410)  评论(0编辑  收藏  举报