HTTPRequest Response Session



final StringBuilder message = new StringBuilder();
message.append("<" + endTimes + ">, " + request.getRequestURL() + request.getQueryString() + ", End Time :: ");


final Enumeration e = request.getAttributeNames();
message.append("Request Attributes: \\n");
while (e.hasMoreElements())
{
final String name = (String) e.nextElement();
if (request.getAttribute(name) instanceof String || request.getAttribute(name) instanceof Exception)
{
message.append(name + ": " + request.getAttribute(name) + "\\n");
}
}
message.append((ex == null ? "" : ex.getMessage()) + " Enddddd " + (System.currentTimeMillis() - endTimes));
logger.error(message.toString());




// http://stackoverflow.com/questions/17112852/get-the-new-record-primary-key-id-from-mysql-insert-query
// final long startTime = System.currentTimeMillis();
// final StringBuilder message = new StringBuilder();
// if (request.getQueryString() != null && !request.getQueryString().isEmpty())
// {
// ;
// }
//
// message.append("<" + startTime + ">, " + request.getRequestURL() + request.getQueryString() + ", Start Time :: ");
// message.append("User::" + request.getRemoteUser());
// message.append("User2::"
// + ((request.getUserPrincipal() == null) ? request.getUserPrincipal() : request.getUserPrincipal().getName()));
// final HttpSession session = request.getSession();
// // session.getId();
// // currentSession.getUser().getUid()
//
// //// use session to store logic
// //if(session.getAttribute("euesessionID")==null) {
// //session.setAttribute("euesessionID", true);
// //// update session record
// //}
//
// final Enumeration e = request.getSession().getAttributeNames();
// message.append("Session: \\n");
// while (e.hasMoreElements())
// {
// final String name = (String) e.nextElement();
// message.append(name + ": " + session.getAttribute(name) + "\\n");
// }
//
// message.append("<H3>Here are some vital stats on your session:</H3>");
// message.append("Session id: " + session.getId() + " \\n");
// message.append("New session: " + session.isNew() + "\\n");
// message.append("Timeout: " + session.getMaxInactiveInterval());
// message.append("<I>(" + session.getMaxInactiveInterval() / 60 + " minutes)</I>\\n");
// message.append("Creation time: " + session.getCreationTime());
// message.append("<I>(" + new Date(session.getCreationTime()) + ")</I>\\n");
// message.append("Last access time: " + session.getLastAccessedTime());
// message.append("<I>(" + new Date(session.getLastAccessedTime()) + ")</I>\\n");
//
// final Enumeration headerNames = request.getHeaderNames();
// message.append("Headers: \\n");
// while (headerNames.hasMoreElements())
// {
// final String key = (String) headerNames.nextElement();
// final String value = request.getHeader(key);
// message.append(key + ": " + value + "\\n");
// }
//
// final Cookie cookies[] = request.getCookies();
// if ((cookies != null) && (cookies.length > 0))
// {
// for (int i = 0; i < cookies.length; i++)
// {
// final Cookie c = cookies[i];
// message.append(c.getName() + ": " + c.getValue() + "\\n");
// }
// }
//
// final JaloSession currentSession = JaloSession.getCurrentSession();
// if (currentSession != null)
// {
// if (currentSession.getUser() != null)
// {
// message.append(currentSession.getUser().getUid() + "\\n");
// }
// if (currentSession.getCart() != null)
// {
// message.append(currentSession.getCart().getStatusInfo() + "\\n");
// }
// }
//
// final Collection<String> coll = response.getHeaderNames();
// message.append("Printing Response Header...\\n");
// final Iterator<String> itr = coll.iterator();
// while (itr.hasNext())
// {
// final String header = itr.next();
// message.append(header + ": " + response.getHeader(header) + "\\n");
// }
//
// message.append("Requested session ID from cookie: " + request.isRequestedSessionIdFromCookie() + "\\n");
// message.append("Requested session ID from URL: " + request.isRequestedSessionIdFromURL() + "\\n");
// message.append("Requested session ID valid: " + request.isRequestedSessionIdValid() + "\\n");
//
// message.append("<H3>Test URL Rewriting</H3>" + request.getRequestURI() + "\\n");
// message.append("<H3>Request Length</H3>" + request.getInputStream().available() + "\\n");
// message.append("<H3>Request Source</H3>" + request.getRemoteHost() + request.getRemoteAddr() + "\\n");
// message.append("code" + response.getStatus());
//
// logger.error(message.toString());





// // TODO eue request id is not null, update database record
// final long endTime = System.currentTimeMillis();
// final StringBuilder message = new StringBuilder();
// message.append("Printing Response Header...\\n");
// final Collection<String> coll = response.getHeaderNames();
// message.append("<" + endTime + ">, " + request.getRequestURL() + request.getQueryString() + ", End Time :: ");
// final Iterator<String> itr = coll.iterator();
// while (itr.hasNext())
// {
// final String header = itr.next();
// message.append(header + ": " + response.getHeader(header) + "\\n");
// }
// final Enumeration headerNames = request.getHeaderNames();
// message.append("Headers: \\n");
// while (headerNames.hasMoreElements())
// {
// final String key = (String) headerNames.nextElement();
// final String value = request.getHeader(key);
// message.append(key + ": " + value + "\\n");
// }
// message.append("<H3>Response Length</H3>" + "\\n");
// message.append((ex == null ? "" : ex.getMessage()) + " Enddddd");
// logger.error(message.toString());
// super.afterCompletion(request, response, handler, ex);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值