This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes URL in browser appears out of sync with the view Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "URL in browser appears out of sync with the view" Watch "URL in browser appears out of sync with the view" New topic
Author

URL in browser appears out of sync with the view

Ashley Bye
Ranch Hand

Joined: Jan 30, 2013
Posts: 46

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?

Thanks


"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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ashley Bye
Ranch Hand

Joined: Jan 30, 2013
Posts: 46

Ok, thanks. I thought with redirect, I loose any information that has been submitted, i.e. via get or post. How do I get around that?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

The JSF "redirect" is not the same as the HTTP redirect. It is part of JSF navigation and the backing beans carry the data, not the URL or the form.
Ashley Bye
Ranch Hand

Joined: Jan 30, 2013
Posts: 46

My misunderstanding! Thanks for your help Tim.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL in browser appears out of sync with the view
 
Similar Threads
why my web pages are downloadable?
jsessionid always appended to urls on first request
Container restart required for jsp changes?
Validating my understanding of JSF
c:import with Facelets