1

In my JSF 2 I use form based authentication. The web.xml contains a single login.html entry.

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>testDB</realm-name>
    <form-login-config>
        <form-login-page>/login.html</form-login-page>
        <form-error-page>/loginError.html</form-error-page>
    </form-login-config>
</login-config>

The web app has a main page (/app/index.html) and a /app/mobile/index.html to support mobile phones.

I would like to use different layouts in login.html, based on the target URL.

  • if the target URL is /app/mobile/index.html, use a login page which is optimized for small browser sizes

  • otherwise use the default login page

The login page (login.html) page is a JSF page.

Is it possible to get the 'destination' page within the login page with JSF, maybe using information in the FacesContext?

mjn
  • 36,362
  • 28
  • 176
  • 378

1 Answers1

0

I found a way to get the destination request URI at https://stackoverflow.com/a/5820573/80901

The expression

#{requestScope['javax.servlet.forward.request_uri']}

contains the value /app/index.html or /app/mobile/index.html

Code example:

    <h:panelGroup rendered="#{requestScope['javax.servlet.forward.request_uri'] eq '/app/mobile/index.html'}">
        <h2>
            Welcome to the MOBILE login page.
        </h2>
    </h:panelGroup>
    <h:panelGroup rendered="#{requestScope['javax.servlet.forward.request_uri'] ne '/app/mobile/index.html'}">
        <h2>
            Welcome to the NON-MOBILE login page.
        </h2>
    </h:panelGroup>
Community
  • 1
  • 1
mjn
  • 36,362
  • 28
  • 176
  • 378