java - Is it possible to forward or redirect from a servlet filter after the response has been committed? -


The argument is that the filter gets hit, the position is not correct, so it goes through the filter chain. After the reaction, the filter gets hit, and the situation is now true (request feature was set). It goes into forwarding, but the page never goes forward. I know that something like this is being done with this reaction because I have tested various arguments, from where it first goes ahead before killing the chain, and it comes forward successfully.

  public void doFilter ServletRequest request, ServletResponse response, FilterChain series) IOException throws, ServletException {HttpServletRequest httpServletRequest = (HttpServletRequest) request; If (some condition is equal to true) {httpServletRequest.getRequestDispatcher ("/ home.jsp"). Forwarded (request, response); Return; } And {chain.doFilter (request, response); }}  

Example of my deployment statement:

     

a HttpServletResponse is actually One way to say that feedback headers are written in the underlying socket or not. A "committed" response (at least) the first line is written. Since the first line of feedback contains the status code, it is because you can not change the status code of a committed response ... and that means it is too late to redirect to change the status to 3xx . Similarly, you can not forward a local because you have already started sending the feedback.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -