Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL in browser appears out of sync with the view

 
Ashley Bye
Ranch Hand
Posts: 132
2
Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18165
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ashley Bye
Ranch Hand
Posts: 132
2
Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18165
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
2
Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My misunderstanding! Thanks for your help Tim.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic