MyRequestProcessor.java
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:2k
- package test;
- import java.util.Enumeration;
- import javax.servlet.http.Cookie;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.RequestProcessor;
- public class MyRequestProcessor extends RequestProcessor {
-
- public MyRequestProcessor() {}
-
- public boolean processPreprocess(HttpServletRequest request,
- HttpServletResponse response) {
-
- log("-------------- My Logging Start--------------");
- log("Request URI = " + request.getRequestURI());
- log("Context Path = " + request.getContextPath());
-
- Cookie cookies[] = request.getCookies();
- if (cookies != null) {
- log("Cookies:");
- for (int i = 0; i < cookies.length; i++) {
- log(cookies[i].getName()
- + " = " + cookies[i].getValue());
- }
- }
-
- Enumeration headerNames = request.getHeaderNames();
- log("Request Header:");
- while (headerNames.hasMoreElements()) {
- String headerName =
- (String)headerNames.nextElement();
- Enumeration headerValues =
- request.getHeaders(headerName);
- while (headerValues.hasMoreElements()) {
- String headerValue =
- (String)headerValues.nextElement();
- log(" " + headerName + " = " + headerValue);
- }
- }
- log("Locale = " + request.getLocale());
- log("Method = " + request.getMethod());
- log("Path Info = " + request.getPathInfo());
- log("Protocol = " + request.getProtocol());
- log("Remote Address = " + request.getRemoteAddr());
- log("Remote Host = " + request.getRemoteHost());
- log("Remote User = " + request.getRemoteUser());
- log("Requested Session Id = "
- + request.getRequestedSessionId());
- log("Scheme = " + request.getScheme());
- log("Server Name = " + request.getServerName());
- log("Server Port = " + request.getServerPort());
- log("Servlet Path = " + request.getServletPath());
- log("Secure = " + request.isSecure());
- log("-------------- My Logging End --------------");
- return true;
- }
- }