Question

In our application we use jsf,we have to redirect the user to home page after their session will be expired.For that i need a path of the home page which i kept in my logout managed bean as a managed bean property.But after session expired if i try to access that it will arise null pointer exception(managed bean becomes null).Then i have decide to try alternative (i.e)create logout class manually and try to access the property, at that time the property which i wants to access is become null.How can i access that property? Please help me. Thanks in advance.

Was it helpful?

Solution

In addition to the previous answer:

You could use (in web.xml)

<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>viewexpired.jsp</location>
</error-page>

Or Context Parameters instead of Session Attributes. See:

Or use (in faces-context.xml)

<managed-bean-scope>application</managed-bean-scope> 

for your bean, so it will stay independent from the session.

OTHER TIPS

Correct way of doing this is declaring exception handler factory in faces-config.xml, then implementing the factory by subclassing javax.faces.context.ExceptionHandlerFactory, and then overriding handle() method in your implementation of javax.faces.context.ExceptionHandlerWrapper. There you should analyze the exception for the ViewExpiredException class and redirect to your view expired page in that case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top