Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot forward after response has been committed error after a sendRedirect

873078Jul 24 2012 — edited Jul 24 2012
Hi,

I have been looking for on Google and other forums information about this error, but nothing solution works with my application.

In my JSF Tool, I effort an java.lang.NumberFormatException. When this error is catched, the flow goes to my SecurityFilter class and in the doFilter method I declare a sendRedirect method. But when this is executed I'm only obtain *"java.lang.IllegalStateException: Cannot forward after response has been committed"*

The error is launched when the application is trying lo load a table into a form.

The code is the next:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
HttpServletResponse resp = (HttpServletResponse) response;

try{
chain.doFilter( request, response );
}
catch(ServletException e){
resp.sendRedirect("/app/error/errorPage.jsf") ; // This line is the executed
return ;
}
catch(Exception e){
resp.sendRedirect("/app/error/errorPage.jsf") ;
}
}

If I write

FacesContext.getCurrentInstance().getExternalContext().redirect("/app/error/errorPage.jsf");

An NullPointerException is catched.

Some clue to solve? Thanks
This post has been answered by gimbal2 on Jul 24 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2012
Added on Jul 24 2012
6 comments
4,389 views