Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can JSF 2.0 navigation model replace Servlets filters?

 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following usecase:

If the user requests "show.xhtml" (by clicking a link or button from another page or just by entering the URL of this page) without login, then he/she will be forwarded to "login.xhtml"

The above mentioned usecase is very common in web applications & Servlet Filters can be a straightforward way of implementing this.

But I wonder how to implement this using the new JSF 2.0 navigation model? Can anyone show a typical example entry in the faces-config.xml?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSF, you wouldn't normally request "show.xhtml". You'd request something like "show.jsf" and the JSF framerok would have been instructed (via web.xml) to fetch the show.xhtml file and use it as a rendering template. Actually, you're probably going through Facelets, but the net effect is the same.

People use filters with JSF for login control all the time. I don't recommend it, since my experience with user-provided login services has been almost uniformly bad (Swiss cheese has nothing on Do-It-Yourself security systems when it comes to gaping holes). Which is one of a bout a dozen reasons why I promote using Java's own container-based security system instead.

Nevertheless, an awful lot of projects use filters for so-called security, and many of them are JSF based.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually my question was not about login security.

I asked whether the JSF 2.0 navigation model is an alternative to Servlet filters!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you framed your question in terms of directing to a login page, so you got a login answer. Complete with absolutely gratis opinion.

Normally, I don't redirect people via filters, since filters are in a layer above the normal app flow and therefore may not be aware of the app business and display contexts. Especially when the display context is as complex as JSF's can be. I do have a JSF app with a filter in it, but it's actually attempting to intercept context timeout problems and attempt to recover from them - which typically does involve re-routing them to a JSF page, since the old page context is gone and a new one must be created from scratch. One of my major complaints about JSF.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you replace Servlet filter with JSF 2.0 navigation model? This is my question.

Please anyone who has knowledge & experience with JSF 2.0 reply this post.

Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic