FacesContext.getExternalContext().getRequest should point you towards
the servlet request.
Werner
Georg Füchsle schrieb:
> Hallo all,
>
> when a session of an user timed out I display a Website telling 'Your
> Session expired; please login again!".
> Now I have to distinguish some 'loginType' of the user.
> If the user initially logged on by ldap i have to redirect him to
> another site as if he logged in by internal mechanisms.
>
> So I have to access the user's logintype data after the session timed out.
>
> I was thinking on a solution without using cookies:
> To do so, I put the loginType data to a hidden input field on the
> website. I thought that this data is not lost doing a request after
> session timeout.
>
> Unfortunately at the restoreview-Phase the data was not already
> written to the bean.
>
> But I think: in the request there will be sent also the information
> from the old (session timed out) page. So I also should be able to
> read the value of this input-field 'loginType'. Is there any
> possibility to read from the request?
>
> Can anybody tell me if I am right, and tell me how to read this data?
>
> I use JSF Tomahawk and Facelets.
>
>
> Thanks!
>
>
>
> Here my input-text:
>
>
>
> <t:inputText value="#{mbUser.loginType}"
> id="loginType"
> immediate="true"
> style="display:none;visibility:hidden;"/>
>
>
>
>
>
> here my PhaseListener:
>
>
> class PhaseListener
> {
>
> public void beforePhase(PhaseEvent event)
> {
> if(event.getPhaseId() == PhaseId.RESTORE_VIEW)
> {
> /*
> before processing any request, I control if the User is
> logged in
> to the application:
> */
> UserBean user = JsfUtils.getUserBean();
>
> if(!user.loggedIn())
> {
> /*
> User is not logged in!
> */
> ExternalContext extCtx =
> event.getFacesContext().getExternalContext();
> HttpServletRequest request =
> (HttpServletRequest) extCtx.getRequest();
> String reqUri = request.getRequestURI();
>
> if(startOrErrorPageIsCalled(reqUri))
> {
> /*
> Users that are not logged in are only
> allowed to see the
> login-page or the error pages...
> */
> return;
> }
> else
> {
> /*
> Users that is not logged in tried to
> request the application.
> I want to redirect him to a page
> 'sessionExpired' depending on
> his former loginType; this loginType I want to save on the website;
> */
>
> // HERE THE LOGINTYPE WAS NOT reset to
> the Bean. is there any
> other possibility to read this value from the request?
> if(user.getLoginType() == 1)
> {
>
> event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot()
> + "sessionExpired.jsf");
> }
> else
> {
> // redirect him to another
> website
> }
> }
> }
>
> }
> }
>
>
> }
>