How to solve ViewExpiredException in JSF 1.2

社会主义新天地 提交于 2019-12-05 16:12:45
BalusC

You can solve it by setting the state saving method to client instead of server so that views are stored (in serialized form, of course) in a hidden input field of the POST form, instead of in the session in the server side (which is in turn to be referenced by JSESSIONID cookie; so all views will basically get lost when you delete the session cookie or when the session expires). You can do that by adding the following context parameter to the web.xml:

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

If the above is not an option for some reason, then best what you could do is to handle it gently as an error page in web.xml as follows:

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/errors/sessionexpired.jsf</location>
</error-page>

This does not solve the exception, but it at least offers you the opportunity to tell in the error page the enduser about the problem and what actions the enduser has to take. You could even let the error page point to the login page and conditionally render some message about why the enduser is facing the login page again.

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!