tag:blogger.com,1999:blog-36773632.post9031094484498024795..comments2023-12-19T08:40:05.062-05:00Comments on Java Evangelist John Yeary: JSF 2 Tip of the Day: JSF Page Redirection in PhaseListenerJohn Yearyhttp://www.blogger.com/profile/00461192445071361043noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-36773632.post-36340289784987540832012-05-25T16:46:25.493-05:002012-05-25T16:46:25.493-05:00No I don't want to redirect after a session is...No I don't want to redirect after a session is expired. This is just a general purpose example of how to do it with a PhaseListener. Please don't read too much into it. The example is supposed to give you ideas. ;-)<br /><br />The PhaseListener allows you to get the FacesContext and make decisions should you choose to do so.John Yearyhttps://www.blogger.com/profile/00461192445071361043noreply@blogger.comtag:blogger.com,1999:blog-36773632.post-63522861099659713642012-05-25T14:21:17.672-05:002012-05-25T14:21:17.672-05:00Hi John,
You want to redirect base on the value of...Hi John,<br />You want to redirect base on the value of HttpSession, and also your outcome view is static, I am assume that you want to redirect to login page after session expired. If that is the case, I feel like Filter should be a better use here (as Filter is great for block, redirect or modify the request). In Filter, you can obtain the session by:<br /><br />request.getSession(false)<br /><br />and if the HttpSession is null, then you can<br /><br />response.sendRedirect("login.xhtml");Thang Phamhttps://www.blogger.com/profile/12898880509356389303noreply@blogger.com