I have come across a problem in which Pretty Faces will result in an infinite loop, ended by my Browser: Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
The exact cause of the problem
File structure
pretty-config.xml fragment
<url-mapping id="login">
<pattern value="/login" />
<view-id value="/login/login.xhtml" />
</url-mapping>
<url-mapping id="register">
<pattern value="/register" />
<view-id value="/login/register.xhtml" />
</url-mapping>
Description
Navigation to localhost:8080/register
will result in my webpage.
Navigation to localhost:8080/login
will result in the described loop, note that the navigation will result in redirection to localhost:8080/login/
<-- a trailing slash.
My guess, localhost:8080/login
is a request for the folder login
. But I do not know how to fix it, so my request for localhost:8080/login
will result in the webpage.
Thanks in advance.
My only guess is that your FacesServlet
is mapped to *.xhtml
so when a request is processed, first your pretty filter forwards it to your FacesServlet, but, because your xhtml files are in the path, the forward is then again processed by your pretty filter ad infinitum.
To solve it, put your views inside the WEB-INF folder and in your pretty.config.xml
put something like this:
<url-mapping id="login">
<pattern value="/login/" />
<view-id value="/WEB-INF/views/login.xhtml" />
</url-mapping>
This way the path intercepted by the filter is not the same of your servlet because clients can request resources in the WEB-INF
folder