aspose file tools*
The moose likes JSF and the fly likes Can JSF 2.0 navigation model replace Servlets filters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Can JSF 2.0 navigation model replace Servlets filters?" Watch "Can JSF 2.0 navigation model replace Servlets filters?" New topic
Author

Can JSF 2.0 navigation model replace Servlets filters?

Namitha karupaiya
Ranch Hand

Joined: Mar 10, 2004
Posts: 89
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

Joined: Jun 25, 2001
Posts: 15662
    
  15

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.


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

Joined: Mar 10, 2004
Posts: 89
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

Joined: Jun 25, 2001
Posts: 15662
    
  15

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

Joined: Mar 10, 2004
Posts: 89
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can JSF 2.0 navigation model replace Servlets filters?
 
Similar Threads
Basic JSF design question
Questions about JavaServer Face
[ANNOUNCE] JSF 2.0 Wish List
Resource reference error
JSP vs JSF ?!!