我们经常需要在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基础 pickle.dump和load 对一个对象进行序列化存储及读取

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

  2. numpy.random.randn()与rand()的区别【转】

    本文转载自:https://blog.csdn.net/u010758410/article/details/71799142 numpy中有一些常用的用来产生随机数的函数,randn()和rand( ...

  3. 苹果电脑macbook 安装 Burp Suite pro_v1.7.37破解版

    1.先去官网下载最新版本 Burp Suite Community Edition v1.7.36安装完成 https://portswigger.net/burp/communitydownload ...

  4. 51nod 1003 阶乘后面0的数量

    每一个 2 与一个 5 相乘,结果就增加一个零. 所以求 n! 后面的连续零的个数,其实就是求其中相乘的数含有因子每对因子 2 与 5  的个数. 又因为从1到某个数,所含 2 的个数比 5 多,所以 ...

  5. NS3 fifth.cc 拥塞窗口实例

    fifth.cc /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This progr ...

  6. 08_Flume_Selector实践

    实践一:replicating selector 1.目标场景 selector将event复制,分发给所有下游节点 2.Flume Agent配置 Agent配置 # Name the compon ...

  7. go 字符串拼接

    s := "hello," m := " world" a := s + m fmt.Printf("%s\n", a)

  8. python 千位分隔符,

    >>>) >>>'1,234,567,890'

  9. [ios]自定义UI

    参考:http://blog.sina.com.cn/s/blog_7b9d64af0101edqf.html 回忆一下,这么个场景. 我们在一个界面上,要排列多个相同的元素.你马上就可以想到: 1. ...

  10. java数组声明和变式--record1

    ​ java声明数组方式: String[] namelist; int numlist[];//此声明为动态声明,不能指定长度,numlist[10] 静态声明的方式: int a[]={1,2,3 ...