1

My environment is: NetBeans7.2.1, GlassFish3.1, JSF2 and Weld 1.1.0.

I'm trying to redirect to an error page in one of these cases ( session/conversation/view timeout ).

From what I read there are number of options:

  1. Using <error-page> inside web.xml (but for some reason when I use location with error.xhtml page it's not working, only with a servlet - asked this question about this issue).

  2. Using <exception-handler-factory> inside faces-config.xml which will use a CustomExceptionHandler like in this example.

  3. Using a @WebFilter like in this example.

My main problem is that after I'm redirecting to error.xhtml page I want to disable going back to previous pages. so even if the user clickes on the back button he will still be redirected to the error page.

I was able to redirect to an error page when an exception accourd , but was not able to clear the cache so when the user goes back he still can see the previous page content.

I don't fully understand what are the diffrances between the 3 options above, and exactly what is the role of each option.

Can someone please explain ?

what is the diffrence between

NavigationHandler nav = fc.getApplication().getNavigationHandler(); nav.handleNavigation(fc, null, "/error"); facesContext.renderResponse();

and

((HttpServletResponse)response).sendRedirect("yourCustomJSF.jsf"); ?

How can I handle these exceptions by redirecting and clearing the cache so that the user will not be able to see previous page ?

Thank's In Advance.

Community
  • 1
  • 1
user2046810
  • 393
  • 1
  • 8
  • 21

2 Answers2

0

You can use this for handle expired session/view:

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/index.jsf</location>
</error-page>
Joffrey Hernandez
  • 1,809
  • 3
  • 21
  • 39
0

My main problem is that after I'm redirecting to error.xhtml page I want to disable going back to previous pages. so even if the user clickes on the back button he will still be redirected to the error page

to do this use a filter to not cache the page and send the request to the server instead see this to get the code of filter

https://stackoverflow.com/a/19034603/2422368

Community
  • 1
  • 1
hanan Ahmed
  • 442
  • 3
  • 5