HttpServletRequest req = (HttpServletRequest) request;

String context = ((HttpServletRequest) request).getContextPath().toString(); // 工程名 如:/fileUpload

String uri = ((HttpServletRequest) request).getRequestURI().toString(); // 不包含域名的url 如:/fileUpload/index.jsp
String url = ((HttpServletRequest) request).getRequestURL().toString(); // 完整url 如:http://localhost:8080/fileUpload/index.jsp

String path = uri.substring(context.length()); // 访问路径 如: /index.jsp


String host = req.getRemoteHost(); // 获得客户端的主机名。
String addr = req.getRemoteAddr(); // 获得客户端的ip地址
int portRemote = req.getRemotePort(); // 返回发出请求的客户机的端口号。
String user = req.getRemoteUser();

String prot = req.getScheme(); // 协议名
String sn = req.getServerName(); // 服务器域名
String server = req.getServletPath(); // 同path
String user1 = req.getLocalAddr(); // 服务器ip
int user2 = req.getLocalPort(); // 服务器端口
int port = req.getServerPort(); // 应用端口
String p = req.getProtocol(); // HTTP1.1
String params = req.getQueryString(); //返回请求行中的参数部分,?号后的字符串参数
Map map = req.getParameterMap();// 以map形式返回参数


String headerParam1 =req.getHeader("x-forwarded-for"); // 获取请求头中的数据

// 请求头
String ua = req.getHeader("User-Agent"); //Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
String ref = req.getHeader("referer"); // 获取来源url(从这个url对应的页面跳转过来的)
req.getServletContext();
String realPath = req.getServletContext().getRealPath("/");



Set paramKeySet = req.getParameterMap().keySet();
String keyString = paramKeySet.toString();

HttpSession session = req.getSession();

if(keyString.indexOf("{")!= -1 || keyString.indexOf(":")!= -1 || keyString.indexOf("debug")!= -1 || keyString.indexOf("redirect")!= -1){
throw new RuntimeException("===恶意连接:参数包含{或\":\"或dubug或redirect");

}