Reputation: 53
I have a web application that originally was a JSF app, but has been migrated to pure HTML/JavaScript. We are now in the progress of eliminating JSF completely.
We had the physical file main.xhtml, which was requested by "main.jsf", where the FacesServlet was declared in web.xml with url-mapping *.jsf.
We have moved the content to main.html, and put a meta-tag REFRESH in main.xhtml to redirect to main.html.
Now the problem is that even if I remove FacesServlet from web.xml, it still redirects the request for main.jsf to main.xhtml. If I rename the file main.xhtml to main.jsf, requesting main.jsf gives a 404, and the server log says it cannot find a file "main.jsp".
Now the question is: If it redirects *.jsf to *.jsp or *.xhtml even when there is no FacesServlet in web.xml, what is responsible for this redirections?
I'm using GlassFish 3.1.2.2.
Upvotes: 2
Views: 698
Reputation: 1108972
When using JSF 2.0+ on a Servlet 3.0+ container, and there's no explicit FacesServlet
registration in webapp's own web.xml
, then the FacesServlet
will during webapp's startup automatically be registered on URL patterns /faces/*
, *.faces
and *.jsf
.
See also its javadoc:
This servlet must automatically be mapped if it is not explicitly mapped in
web.xml
orweb-fragment.xml
and one or more of the following conditions aretrue
.
A
faces-config.xml
file is found inWEB-INF
A
faces-config.xml
file is found in theMETA-INF
directory of a jar in the application's classpath.A filename ending in
.faces-config.xml
is found in theMETA-INF
directory of a jar in the application's classpath.The
javax.faces.CONFIG_FILES
context param is declared inweb.xml
orweb-fragment.xml
.The
Set
of classes passed to theonStartup()
method of theServletContainerInitializer
implementation is not empty.If the runtime determines that the servlet must be automatically mapped, it must be mapped to the following
<url-pattern>
entries.
/faces
*.jsf
*.faces
JSF 2.3 will add *.xhtml
URL pattern to the set (which is backported in Mojarra 2.2.11).
If you want to stop this behavior, and you can't eliminate the triggers (e.g. still having a faces-config.xml
), then your best bet is to explicitly register FacesServlet
on *.xhtml
in webapp's own web.xml
. This will override the default auto registered URL patterns.
Upvotes: 2