I have created a JSF 2.0 application as shown in the Eclipse Documentation with the Eclipse Indigo and Tomcat 7.0.32.
In this application I have two pages:
- login.xhtml
- welcome.xhtml
From login.xhtml I am navigation to welcome.xhtml.
And I have declared the login.xhtml as the welcome page in my web.xml.
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
And also defined the url-pattern for Faces Servlet as:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Now I am having two issues:
- When I am accessing the URL
http://localhost:8080/LibraryInformationSystem/I can see the login page, but after login, when I am being navigated to the welcome.xhtml, the URL is changing tohttp://localhost:8080/LibraryInformationSystem/login.xhtmlnothttp://localhost:8080/LibraryInformationSystem/welcome.xhtml; but if I manually browsehttp://localhost:8080/LibraryInformationSystem/welcome.xhtml, it is also showing same thing. My question is why the URL is not changing? Is it the right way to define the default page? I have found information from two other SO threads, first one is here and the second one is here. - The second problem is, when I am running the application from Eclipse and when it launches the application to its internal browser, I can see the login page, but if I shutdown the server running from Eclipse and run the Tomcat from the batch file startup.bat which resides in bin folder and export the application as a war file and deploy it into the webapps folder, sometime I can see the login page, sometime I am having the Tomcat’s HTTP Error – 404 page, from Firefox or Chrome. If I close the startup.bat and delete the myapplication.war and myapplication folder from the webapps folder, then again start the server from startup.bat and again export the war from Eclipse I can see the login page, in this case no 404 error. Why it is happening?
Any pointer would be very helpful to me.
About point 1), JSF breaks the HTTP semantics. It should be using a GET to provide the contents of
http://localhost:8080/LibraryInformationSystem/welcome.xhtml, but JSF uses POST so the URL does not change. You can do aPost-Redirect-Getto update the URL, but it is not how JSF works by default.About point 2, you should avoid making two questions in the same SO question.