我有一个过滤器,以记录他们处理请求,这样我就可以跟踪哪些会话在什么时候什么请求参数打的页面。 伟大工程......从JSP张贴到JSP,或进行到JSP的直接调用。 当窗体发布到转发该请求到一个新的JSP一个servlet,但是,我无法看到哪个JSP请求被转发到。
例如,假设我有一个登录页面,其职位,以一个LoginServlet,然后将请求转发给任一的index.jsp或index1.jsp。 我怎样才能从请求确定LoginServlet是否返回的index.jsp或index1.jsp?
这是在使用2.3 servlet规范一个Java 1.5环境。
public class PageLogFilter implements Filter {
FilterConfig filterConfig = null;
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
}
public void destroy() {
this.filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
try {
if (request instanceof HttpServletRequest) {
HttpServletRequest req = (HttpServletRequest) request;
HttpSession session = req.getSession(false);
//For non-forwards, I can call req.getRequestURI() to determine which
//page was returned. For forwards, it returns me the URI of the
//servlet which processed the post. I'd like to also get the URI
//of the jsp to which the request was forwarded by the servlet
}
}
} catch (Exception e) {
System.out.println("-- ERROR IN PageLogFilter: " + e.getLocalizedMessage());
}
chain.doFilter(request, response);
}
}