リクエスト情報出力
private void printRequest(HttpServletRequest req) {
System.out.println("AuthType :" + req.getAuthType());
System.out.println("CharacterEncoding :" + req.getCharacterEncoding());
System.out.println("ContentLength :" + req.getContentLength());
System.out.println("ContentType :" + req.getContentType());
System.out.println("ContextPath :" + req.getContextPath());
System.out.println("LocalAddr :" + req.getLocalAddr());
System.out.println("LocalName :" + req.getLocalName());
System.out.println("LocalPort :" + req.getLocalPort());
System.out.println("Method :" + req.getMethod());
System.out.println("PathInfo :" + req.getPathInfo());
System.out.println("PathTranslated :" + req.getPathTranslated());
System.out.println("Protocol :" + req.getProtocol());
System.out.println("QueryString :" + req.getQueryString());
System.out.println("RemoteAddr :" + req.getRemoteAddr());
System.out.println("RemoteHost :" + req.getRemoteHost());
System.out.println("RemotePort :" + req.getRemotePort());
System.out.println("RemoteUser :" + req.getRemoteUser());
System.out.println("RequestedSessionId:" + req.getRequestedSessionId());
System.out.println("RequestURI :" + req.getRequestURI());
System.out.println("RequestURL :" + req.getRequestURL());
System.out.println("Scheme :" + req.getScheme());
System.out.println("ServerName :" + req.getServerName());
System.out.println("ServerPort :" + req.getServerPort());
System.out.println("ServletPath :" + req.getServletPath());
Cookie[] cookie = req.getCookies();
for(int i = 0; cookie != null && i < cookie.length; i++) {
System.out.println(
"Cookie[" + i + "]:" +
cookie[i].getName() + "=>" +
cookie[i].getValue() + "," +
cookie[i].getDomain() + "," +
cookie[i].getPath() + "," +
cookie[i].getComment()
);
}
Enumeration enu1 = req.getParameterNames();
while(enu1 != null && enu1.hasMoreElements()) {
Object obj = enu1.nextElement();
String[] strAry = req.getParameterValues((String)obj);
if(strAry.length == 1) {
System.out.println("Parameter[" + obj + "]:" + strAry[0]);
} else {
for(int i = 0; i < strAry.length; i++) {
System.out.println("Parameter[" + obj + "(" + i + ")]:" + strAry[i]);
}
}
}
Enumeration enu2 = req.getAttributeNames();
while(enu2 != null && enu2.hasMoreElements()) {
Object obj = enu2.nextElement();
System.out.println("Attribute[" + obj + "]:" + req.getAttribute((String)obj));
}
Enumeration enu3 = req.getHeaderNames();
while(enu3 != null && enu3.hasMoreElements()) {
Object obj = enu3.nextElement();
System.out.println("Header[" + obj + "]:" + req.getHeader((String)obj));
}
Enumeration enu4 = req.getSession().getAttributeNames();
while(enu4 != null && enu4.hasMoreElements()) {
Object obj = enu4.nextElement();
System.out.println("Session[" + obj + "]:" + req.getSession().getAttribute((String)obj));
}
}