Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why do I need a forward page to the JSF index page?

 
Jonny Andersson
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read a few chapters from the first edition but have not bought the new edition yet as I not have time to read it yet. But I have been waiting for it as it describes the new and current JSF syntax. And I also hope that the code examples are easier to get up and running if they are written for the new libraries available on the net.

Anyway, here is a little question I feel not understand fully yet ... Why do I have to have a page that forwards so the first page (index page, main page) for the JSF application? What architectural thing prevents me from have the index page for the JSF application configured as the welcome page for the web application? Provided that the Faces servlet is configured to handle that page of course.
 
Hany Shafik
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure, But I guess this was common as there was an old bug in Tomcat that didn't accept a servlet in the welcome files list, however starting from tomcat 5 this issue is fixed. See this old thread Servlet-welcome-file-list
 
Ed Burns
author
Ranch Hand
Posts: 82
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hany Shafik is probably right. In fact, you don't need it. Just make sure that in your <welcome-file-list> you include the proper mapping for the faces servlet. For example,

<welcome-file-list>
<welcome-file>faces/register.xhtml</welcome-file>
</welcome-file-list>

for servlets using /faces/* as the mapping.

This approach also works for error pages.

Ed
 
Jonny Andersson
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hum, it actually worked! I am sure I have tried something like that before without getting it to work but I must have made something wrong. And I like it better this way without more pages than necessary.

Thanks! And I'll promise I will buy your book about JSF 2.0 soon! I learnt a lot from the first edition and have been waiting for this new edition. I particularly appreciated that you explained that much about the framework behind the scenes.
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I will go with Ed Burns,

depends upon our requirement, we can use or avoid index.jsp.
but the question is "Why do I need a forward page to the JSF index page?"
if you are using index.jsp for sure in your application, then definitely you need forward page as to stop our application entering into the JSF life cycle before displaying the initial page of the application.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the most part, any page request made directly by the container doesn't work well with a servlet-dispatched framework such as JSF or Struts. This is especially true of the login JSPs, but error JSPs and other pages of the same sort also have problems. The reason appears to be that the container is invoking the page directly instead of via the normal network channel and not all the necessary context is available. Login pages also have the problem that they're injected as a shunt to a normal page request, so not only does the login page have to be invoked, but the original page request has to be preserved, since once login succeeds, control is re-routed back to where the need for login was detected.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds much like a bug or maybe a missing piece in the specification to me. Is this specific to a Servlet container or Servlet API or is it a known problem for all well-known containers?

Marco
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco Ehrentreich wrote:This sounds much like a bug or maybe a missing piece in the specification to me. Is this specific to a Servlet container or Servlet API or is it a known problem for all well-known containers?

Marco


As far as I'm aware, it's not so much a bug as an acknowledgement that pages presented on behalf of the appserver itself don't get the full resource set that pages requested via http(s) to the application would. In the case of login pages, that's as much for security reasons as anything else, but I can think of several other reasons why this would be desirable behaviour.

I've been digging around in the Sun official docs, and most of the formal specs seem mute on the whole area, but that's given me an excuse to get an updated set of docs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic