我们经常需要在servlet(j2ee13.jar  javax.servlet.http.HttpServletRequest)中,获取请求request的各种数据信息。

请求的URL:   http://10.63.205.120:7001/undwrt/GetRealIP?param=a

可通过下面代码:

    /**
* 通过servlet获取客户端请求request的URL
* http://10.63.205.120:7001/undwrt/GetRealIP?param=a
* */
protected void getURL(HttpServletRequest request){
int ContentLength= request.getContentLength();
String ContentType= request.getContentType();
String CharacterEncoding= request.getCharacterEncoding();
String AuthType= request.getAuthType();
String Method= request.getMethod();
String RemoteAddr= request.getRemoteAddr();
String PathInfo= request.getPathInfo();
String ServerName= request.getServerName();
String Protocol= request.getProtocol();
String QueryString= request.getQueryString();
String RequestURI= request.getRequestURI();
String Scheme= request.getScheme();
int ServerPort= request.getServerPort();
String ServletPath= request.getServletPath(); String RequestURL= request.getRequestURL().toString();
String ContextPath= request.getContextPath(); System.out.println("ContentLength :"+ContentLength);
System.out.println("ContentType :"+ContentType);
System.out.println("CharacterEncoding :"+CharacterEncoding);
System.out.println("AuthType :"+AuthType);
System.out.println("Method :"+Method);
System.out.println("RemoteAddr :"+RemoteAddr);
System.out.println("PathInfo :"+PathInfo);
System.out.println("ServerName :"+ServerName);
System.out.println("Protocol :"+Protocol);
System.out.println("QueryString :"+QueryString);
System.out.println("RequestURI :"+RequestURI);
System.out.println("Scheme :"+Scheme);
System.out.println("ServerPort :"+ServerPort);
System.out.println("ServletPath :"+ServletPath); System.out.println("RequestURL :"+RequestURL);
System.out.println("ContextPath :"+ContextPath);
}

run as:
ContentLength :-1
ContentType :null
CharacterEncoding :GBK
AuthType :null
Method :GET
RemoteAddr :10.63.205.79
PathInfo :null
ServerName :10.63.205.120
Protocol :HTTP/1.1
QueryString :param=a
RequestURI :/undwrt/GetRealIP
Scheme :http
ServerPort :7001
ServletPath :/GetRealIP
RequestURL :http://10.63.205.120:7001/undwrt/GetRealIP
ContextPath :/undwrt

java request获取各种数据的更多相关文章

  1. 5.1 Request 获取请求数据的几种方法

    //获取请求头和请求数据 //请求数据(1.通过超链接 2.通过表单) //获取请求数据的时候一般来说 都要先检查 再使用 public class RequestDemo2 extends Http ...

  2. EXTJS 资料 Ext.Ajax.request 获取返回数据

    下面是一个登陆页面调用的EXTJS login function,通过 url: '/UI/HttpHandlerData/Login/Login.ashx',获取返回登陆账户和密码! Ext.onR ...

  3. 爬虫小探-Python3 urllib.request获取页面数据

    使用Python3 urllib.request中的Requests()和urlopen()方法获取页面源码,并用re正则进行正则匹配查找需要的数据. #forex.py#coding:utf-8 ' ...

  4. Java如何获取JSON数据中的值

    场景:在接口自动化场景中,下个接口发送的请求参数,依赖上个接口请求结果中的值.需要将获取值作为全局参数引用. import java.io.File; import java.io.FileInput ...

  5. request获取ip数据

    http://www.cnblogs.com/icerainsoft/p/3584532.html

  6. jmeter 性能测试 JDBC Request (查询数据库获取数据库数据) 的使用

    JDBC Request 这个Sampler可以向数据库发送一个jdbc请求(sql语句),并获取返回的数据库数据进行操作.它经常需要和JDBC Connection Configuration配置原 ...

  7. request获取请求头和请求数据

    package cn.itcast.request; import java.io.IOException; import java.io.InputStream; import java.io.Pr ...

  8. jmeter JDBC Request (查询数据库获取数据库数据) 的使用

    JDBC Request 这个Sampler可以向数据库发送一个jdbc请求(sql语句),并获取返回的数据库数据进行操作.它经常需要和JDBC Connection Configuration配置原 ...

  9. 转jmeter 性能测试 JDBC Request (查询数据库获取数据库数据) 的使用

    JDBC Request 这个Sampler可以向数据库发送一个jdbc请求(sql语句),并获取返回的数据库数据进行操作.它经常需要和JDBC Connection Configuration配置原 ...

随机推荐

  1. Python3基础 file for+list 读取txt文本 并 一行一行的输出(低效率)

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. JavaScript replaceAll

    网上的: String.prototype.replaceAll = function(str1, str2) { var str = this; var result = str.replace(e ...

  3. 【Django】【四】测试

    [Testing in Django] 通过参数可控制Django项目不同级别的测试. 1. 运行sign应用下所有的测试用例: \\guest\python manage.py test sign ...

  4. shell 杀掉指定进程的服务

    check_results=`ps -ef|grep bp_driver.launch|awk '{print $2}'|sed -n 1p` echo `kill - $check_results` ...

  5. 使用 dplyr 管道操作处理数据框

    关于数据操作的另一个流行的包是dplyr,它发明了一种数据操作语法.dplyr 扩展包并没有使用构建子集函数([ ]),而是定义了一系列基础的变形函数作为数据操作模块,并且引入了一个管道操作符,利用管 ...

  6. 《WAP团队项目需求分析改进》

    基于原型的团队项目需求调研与分析 本项目是一个家教系统的实现,随着时代的进步,现今已经进入信息技术时代,越来越多的人注意到了教育的重要性.家长对于孩子的学习提高注意力,大家都不想自己的孩子输在起跑线上 ...

  7. Thunder团队Final版爱阅app发布视频

    视频链接:https://www.bilibili.com/video/av17008792/ 视频简介:首先出现的是我们团队的logo,接着是Final版爱阅app的功能展示,紧接着是我们团队的开发 ...

  8. WPF StoryBoard用法

    时间:2011-06-15 21:26来源:百度空间 作者:shichen4 点击: 次 StoryBoard使用,Xaml转cs代码 Canvas.Triggers EventTriggerRout ...

  9. 52 53django

    一.需要弄清楚的几个关键点: KEY: 1 Django项目无论多大,只是一个应用程序 2 地址栏发请求默认是GET请求 form表单可以发送get请求,也可以发送post请求 3 浏览器接受的响应体 ...

  10. Hololens 开发环境配置(转)

    转自 Vangos Pterneas, 4 Apr 2016 CPOL 5.00 (1 vote) vote 1vote 2vote 3vote 4vote 5 The past few days h ...