Declaring the Faces servlet is the first necessary step in developing a JSF application. The following XML snippet (from WEB-INF/web.xml) allows the servlet to be declared and specifies that all requests ending in *.jsf are passed to the Faces servlet which routes them to the corresponding JSP page.
<context-param> 
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<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>
I've noticed that when you create a JSF project in NetBeans, a different servlet mapping is used. NetBeans creates a servlet mapping with a url-pattern of /faces/* as shown below:
<servlet-mapping> 
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
I don't know if there is a standard convention to use here or if one is better than the other?
2/8/2011 05:56:38 pm

I’d like to know if you already know what’s the difference in using /faces/* or *.jsf inside url-pattern web.xml tag. I’m studying about it and trying to know what does FacesServlet do with incoming uri from client requests.

Reply



Leave a Reply.