Removing /faces/ from URL in JSF applications - jsf

I have made website using JSF 2.0
All links goes as below.
http://www.mywebsite.com/faces/index.xhtml
What I want is remove /faces/, so that final url would be as below.
http://www.mywebsite.com/index.xhtml
Note: I want to achieve this while passing parameters.
This question is related to my previous question
What I tried is changing filter criteria for my new filter
<filter>
<filter-name>UrlRewrite</filter-name>
<filter-class>com.lab.filter.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewrite</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
TO
<filter>
<filter-name>UrlRewrite</filter-name>
<filter-class>com.lab.filter.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewrite</filter-name>
<url-pattern>/</url-pattern> // here made change from /* to /
</filter-mapping>
But it was giving errors. No web page is showing.
What I want to achieve from previous is mywebsite.com/faces/dr.rajesh to mywebsite.com/dr.rajesh
Full WEB-INF as below.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<filter>
<filter-name>restrict</filter-name>
<filter-class>com.lab.filter.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>restrict</filter-name>
<url-pattern>*.xhtml</url-pattern>
</filter-mapping>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>none</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>UrlRewrite</filter-name>
<filter-class>com.lab.filter.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewrite</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

In your web.xml you just need the url pattern below:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
and remove the other mapping to the Faces Servlet.
In modern JSF versions (>2.1), you don't need any entries in the web.xml at all since the are present 'on' the Faces Servlet via annotations and will be parsed.

Remove the below content from WEB-INF web.xml
<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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>

Related

Error loading css, cannot find "theme.css" resource of "primefaces-Omega" library Primefaces 6.0

I'm using PrimeFaces 6.0 on JSF 2.2 in order to benefit from the new built-in free community theme Omega, however it's doesn't work for me.
In the documentation it's said "To enable omega, set primefaces.THEME context parameter to Omega and that’s it"
I'm not using a maven project
here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>Omega</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</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>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
18000
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
In the primefaces official blog it's written Omega with a capital "O"
hhhh it works by changing it to omega.

RichFaces spacer gif URL wrong after upgrade to JBoss 8 (WildFly)

I'm doing an upgrade from JBoss 6 to JBoss 8 (WildFly). The version of RichFaces 3.3.3 has stayed the same. Several places in the code call the RichText spacer, like this:
<rich:spacer height="15" width="5"/>
In web.xml, the servlet-mapping entries related to Faces looked like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
When running JBoss 6, the spacer image had the following URL, which worked fine:
https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif
We start running into issues when we upgrade to JBoss 8. The URL suddenly looks like this, and returns a 404 Not Found when accessed:
https://host.com/dc/faces/a4j/g/3_3_3.Finalimages/spacer.gif
I tried removing all but the *.jsf servlet-mapping from web.xml, like the documentation specifies. This made the URL look like this:
https://host.com/dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf
The URL returns a 500 Internal Server Error when accessed:
ERROR [io.undertow.request] (default task-29) UT005023: Exception handling request to /dc/a4j/g/3_3_3.Finalimages/spacer.gif.jsf: javax.servlet.ServletException: org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : images/spacer.gif.jsf
The image is always available the original URL.
For reference, here is web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>[clipped]</display-name>
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>mojarra-1.2_15</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.jboss.seam.core.init.debug</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>Disable MyFacesExtensionsFilter check</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfViewsInSession</param-name>
<param-value>5</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.numberOfLogicalViews</param-name>
<param-value>5</param-value>
</context-param>
<servlet>
<servlet-name>Seam Resource Servlet</servlet-name>
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Seam Resource Servlet</servlet-name>
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-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>
<session-config>
<session-timeout>45</session-timeout>
</session-config>
</web-app>
I just assume bypass the issue and do away with the spacer, but the spacer is also called internally by RichFaces, within some of the components that we are currently using.
What should I do to get the spacer to show up correctly?
You should exclude second initialization of org.ajax4jsf.Filter in filter and filter-mapping sections of web.xml. Seam instantiate org.ajax4jsf.Filter from Ajax4jsfFilterInstantiator class.
Please remove following code from web.xml
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
...
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
See related RichFaces Issue RF-3410

java.lang.IllegalArgumentException at coldfusion.filter.FormScope.parseQueryString(FormScope.java:355)

we suddenly started receiving the below errors from ColdFusion 8:
javax.servlet.ServletException: ROOT CAUSE:
java.lang.IllegalArgumentException at
coldfusion.filter.FormScope.parseQueryString(FormScope.java:355) at
coldfusion.filter.FormScope.parsePostData(FormScope.java:327) at
coldfusion.filter.FormScope.fillForm(FormScope.java:277) at
coldfusion.filter.FusionContext.SymTab_initForRequest(FusionContext.java:438)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:33) at
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at
coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126)
at coldfusion.CfmServlet.service(CfmServlet.java:198) at
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at
com.intergral.fusionreactor.filter.FusionReactorCoreFilter.doHttpServletRequest(FusionReactorCoreFilter.java:503)
at
com.intergral.fusionreactor.filter.FusionReactorCoreFilter.doFusionRequest(FusionReactorCoreFilter.java:337)
at
com.intergral.fusionreactor.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:246)
at
com.intergral.fusionreactor.filter.FusionReactorFilter.doFilter(FusionReactorFilter.java:121)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at
jrun.servlet.FilterChain.service(FilterChain.java:101) at
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
at
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:70)
at
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at
jrun.servlet.FilterChain.service(FilterChain.java:101) at
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
I compared to coldfusion configuration of a working server and there is nothing noticeable.
Our default-web.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<!--FusionReactor filter - created Mon Oct 08 12:12:10 CEST 2012-->
<filter>
<filter-name>FusionReactor</filter-name>
<filter-class>com.intergral.fusionreactor.filter.FusionReactorFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>D:/FusionReactor/instance/coldfusion.cfmx8.SRVWWEBT05/conf/reactor.conf</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>FusionReactor</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<display-name>Default Web Application Settings</display-name>
<description>Settings </description>
<!--
<filter>
<filter-name>JRunTimingFilter</filter-name>
<filter-class>jrun.servlet.filters.TimingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>JRunTimingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
<servlet>
<servlet-name>FileServlet</servlet-name>
<servlet-class>jrun.servlet.file.FileServlet</servlet-class>
<init-param>
<param-name>browseDirs</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>ServletInvoker</servlet-name>
<servlet-class>jrun.servlet.ServletInvoker</servlet-class>
</servlet>
<servlet>
<servlet-name>JSPServlet</servlet-name>
<servlet-class>jrun.jsp.JSPServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>keepGenerated</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>translationDisabled</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>cacheTags</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>JSTServlet</servlet-name>
<servlet-class>jrun.jsp.JSTServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>JspLicenseServlet</servlet-name>
<servlet-class>coldfusion.license.JspLicenseServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
<init-param>
<param-name>use-servlet-security</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>JRunStatistics</servlet-name>
<jsp-file>/jrunx/instrument/Results.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>FileServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JspLicenseServlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JSTServlet</servlet-name>
<url-pattern>*.jst</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletInvoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JRunStatistics</servlet-name>
<url-pattern>/JRunStatistics</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--
<error-page>
<exception-type>jrun.jsp.compiler.JSPCompiler$CompoundCompilerException</exception-type>
<location>/jrun/jsp/error-pages/CompoundCompilerException.jsp</location>
</error-page>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/jrun/servlet/error-pages/ServletException.jsp</location>
</error-page>
<error-page>
<exception-type>jrun.jsp.parser.TokenMgrError</exception-type>
<location>/jrun/servlet/error-pages/ServletException.jsp</location>
</error-page>
-->
<error-page>
<exception-type>javax.io.FileNotFoundException</exception-type>
<location>/jrun/servlet/error-pages/404.jsp</location>
</error-page>
</web-app>
do someone has a hint on this?
The issue was related to an .Net Http module that was filtering out every requests on the server and modifying them.

Tomcat Server can not find this Spring ContextLoaderListener class during the server start up

the Error is:
INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener" is already configured for this context. The duplicate definition has been ignored.
mai 14, 2013 11:19:50 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Erreur lors de la configuration de la classe d'écoute de l'application (application listener) org.springframework.web.context.ContextLoaderListener
I try this tutorial http://www.mkyong.com/spring/spring-error-classnotfoundexception-org-springframework-web-context-contextloaderlistener/ but no result.
I use
tomcat 7.0.
jsf 2.0
spring security 3.0.6
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>plateformHotlin</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>redmond</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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.xhtml</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<!-- ////////////////////////// END: FACES RELATED ///////////////////////// -->
<!-- ========================== SPRING RELATED ============================= -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/security-app-context.xml
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/j_spring_security_logout</url-pattern>
</filter-mapping>
<!-- ////////////////////////// END: SPRING RELATED //////////////////////// -->
</web-app>

Remove faces servlet url pattern and page extension from url

i have a command link in my page which looks like:
<h:commandLink value="Add user" action="add?faces-redirect=true" />
and when i click it, it goes to url:
http://localhost:8080/myapp/faces/add.xhtml
but i want the url to be:
http://localhost:8080/myapp/add
how to do that ?
i am using spring 3, jsf 2
this is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>myapp</display-name>
<!-- Add Support for Spring -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<!-- Change to "Production" when you are ready to deploy -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>faces/users.xhtml</welcome-file>
</welcome-file-list>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
You can use PrettyFaces for it.

Resources