This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I've been following along with the Java EE tutorials and noticed that on all of the JSF pages, the URL in the browser bar is a page behind where I actually am. For instance, two pages, greeting.xhtml and response.xhtml, accessed at localhost:8080/contextRoot/. The first view is greeting, you fill in your name and hit send and the next page is greeting.xhtml but response.xhtml is shown. When I then click the button to go back, greeting.xhtml is shown but the browser shows response.xhtml.
Why is this? Is it a standard issue with JSF? How do I prevent it?
"Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover." - Mark Twain
The URL in JSF is more of a "handle" to the JSF session than it is an actual locator. Thus, the text of the URL may not correspond to what View is currently being displayed.
Most of the time, this is just an irritant, but in cases where container-managed security is in use, it is a problem, since the container security is applied based on the incoming URL. For that reason, you can force sync between the URL and the resource name by using the "redirect" element on JSF navigation. Be warned, however, that the redirect does add overhead.
An IDE is no substitute for an Intelligent Developer.