Java 如何从筛选器中确定哪个页面为RequestDispatcher的转发提供服务?

Java 如何从筛选器中确定哪个页面为RequestDispatcher的转发提供服务?,java,servlets,servlet-filters,forward,requestdispatcher,Java,Servlets,Servlet Filters,Forward,Requestdispatcher,我有一个过滤器,它处理请求以记录它们,这样我就可以跟踪哪个会话在什么时间以什么请求参数访问页面。工作很好。。。从jsp发布到jsp,或直接调用jsp。然而,当一个表单被发布到一个servlet,该servlet将该请求转发到一个新的jsp时,我无法看到该请求被转发到了哪个jsp 例如,假设我有一个登录页面,它发布到LoginServlet,然后将请求转发到index.jsp或index1.jsp。如何从请求中确定LoginServlet返回的是index.jsp还是index1.jsp 这是在使

我有一个过滤器,它处理请求以记录它们,这样我就可以跟踪哪个会话在什么时间以什么请求参数访问页面。工作很好。。。从jsp发布到jsp,或直接调用jsp。然而,当一个表单被发布到一个servlet,该servlet将该请求转发到一个新的jsp时,我无法看到该请求被转发到了哪个jsp

例如,假设我有一个登录页面,它发布到LoginServlet,然后将请求转发到index.jsp或index1.jsp。如何从请求中确定LoginServlet返回的是index.jsp还是index1.jsp

这是在使用2.3servlet规范的Java1.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);
}
}

在chain.doFilter.之后调用request.getRequestURI..

如果在chain.doFilter.之前调用,则返回服务servlet的URI,例如/LoginServletyes。。。如果转发请求,请求URI会发生变化幸运的是,它不是Bozho:-恐怕这与Bozho无关。它表明人们在转发后调用getRequestURI时得到了JSP文件。