Friday, 15 May 2015

java - How to set Faces Servlet mapping with security constraint -



java - How to set Faces Servlet mapping with security constraint -

i'm developing jpa,jsf,jaas application , have problem :

i have security-constraint in web.xml

<security-constraint> <web-resource-collection> <web-resource-name>private</web-resource-name> <url-pattern>/*</url-pattern> <http-method>get</http-method> <http-method>post</http-method> </web-resource-collection> </security-constraint> <login-config> <auth-method>form</auth-method> <form-login-config> <form-login-page>/login.xhtml</form-login-page> <form-error-page>/badlogin.xhtml</form-error-page> </form-login-config> </login-config>

so every time application starts user directed login page , page displays hasn't gone through faces servlet , faces components aren't rendered. faces servlet mapping

<servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping>

what's wrong?

just create sure request url matches url pattern of faces servlet.

with current setup, you've 2 options:

either alter

class="lang-html prettyprint-override"><form-login-page>/login.xhtml</form-login-page> <form-error-page>/badlogin.xhtml</form-error-page>

by

class="lang-html prettyprint-override"><form-login-page>/login.jsf</form-login-page> <form-error-page>/badlogin.jsf</form-error-page>

so matches url pattern of faces servlet.

or, change

class="lang-html prettyprint-override"><url-pattern>*.jsf</url-pattern>

by

class="lang-html prettyprint-override"><url-pattern>*.xhtml</url-pattern>

so never need fiddle virtual urls.

java jsf-2

No comments:

Post a Comment