java request获取各种数据
我们经常需要在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获取各种数据的更多相关文章
- 5.1 Request 获取请求数据的几种方法
//获取请求头和请求数据 //请求数据(1.通过超链接 2.通过表单) //获取请求数据的时候一般来说 都要先检查 再使用 public class RequestDemo2 extends Http ...
- EXTJS 资料 Ext.Ajax.request 获取返回数据
下面是一个登陆页面调用的EXTJS login function,通过 url: '/UI/HttpHandlerData/Login/Login.ashx',获取返回登陆账户和密码! Ext.onR ...
- 爬虫小探-Python3 urllib.request获取页面数据
使用Python3 urllib.request中的Requests()和urlopen()方法获取页面源码,并用re正则进行正则匹配查找需要的数据. #forex.py#coding:utf-8 ' ...
- Java如何获取JSON数据中的值
场景:在接口自动化场景中,下个接口发送的请求参数,依赖上个接口请求结果中的值.需要将获取值作为全局参数引用. import java.io.File; import java.io.FileInput ...
- request获取ip数据
http://www.cnblogs.com/icerainsoft/p/3584532.html
- jmeter 性能测试 JDBC Request (查询数据库获取数据库数据) 的使用
JDBC Request 这个Sampler可以向数据库发送一个jdbc请求(sql语句),并获取返回的数据库数据进行操作.它经常需要和JDBC Connection Configuration配置原 ...
- request获取请求头和请求数据
package cn.itcast.request; import java.io.IOException; import java.io.InputStream; import java.io.Pr ...
- jmeter JDBC Request (查询数据库获取数据库数据) 的使用
JDBC Request 这个Sampler可以向数据库发送一个jdbc请求(sql语句),并获取返回的数据库数据进行操作.它经常需要和JDBC Connection Configuration配置原 ...
- 转jmeter 性能测试 JDBC Request (查询数据库获取数据库数据) 的使用
JDBC Request 这个Sampler可以向数据库发送一个jdbc请求(sql语句),并获取返回的数据库数据进行操作.它经常需要和JDBC Connection Configuration配置原 ...
随机推荐
- Wireshark过滤总结
Wireshark提供了两种过滤器:捕获过滤器:在抓包之前就设定好过滤条件,然后只抓取符合条件的数据包.显示过滤器:在已捕获的数据包集合中设置过滤条件,隐藏不想显示的数据包,只显示符合条件的数据包.需 ...
- 获取转UTF8的字符串
/// <summary> /// 获取转UTF8的字符串 /// </summary> /// <param name="strWord">& ...
- Elasticsearch-->Get Started-->Exploring Your Cluster
Version 直接对localhost:9200发出一个get请求 { "name": "WqeJVip", "cluster_name" ...
- 项目梳理4——WebApi项目,使用注释填充Description字段
web.config中添加连接字符串: 为webapi添加Description,使用注释来填充此字段 对于所有引用的xxxx.base项目设置生成的xml文档,注意release.debug下都需设 ...
- java的基本数据类型默认值
这里就举int类型 默认值在类实例化,也就是对象中才有默认值0,或者是静态变量. 1.先看局部变量使用(不行,报错) 2.静态变量 3.类非静态属性
- Future Works on P4
Future Works on P4 P4 and NV: MPvisor, Hyper4, HyperV, Flex4 P4 and NFV P4 and Network Cache P4 and ...
- 贪心算法-Best cow line-字典序问题
代码: #include<cstdio> #include<iostream> #include<stdlib.h> #include<string> ...
- hdu 1370 || poj 1006 简单的中国剩余定理或者暴力
Biorhythms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Probl ...
- 对微服务API服务网关的理解
目录微服务专栏地址目录1. 简介2. 什么是API网关3. 为什么需要API网关4. API网关在微服务架构体系中处于什么位置4.1 调用者眼中的API网关4.2 所处的位置5. 网关技术实现有哪些6 ...
- Spring Boot 启动 Struts 报冲突
错误信息如下: Caused by: com.opensymphony.xwork2.config.ConfigurationException: Bean type class com.opensy ...