This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Odd problem with RichFaces and Servlet Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Odd problem with RichFaces and Servlet Filter" Watch "Odd problem with RichFaces and Servlet Filter" New topic
Author

Odd problem with RichFaces and Servlet Filter

Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
I have noticed that may filter which is supposed to stop people accessing pages without a valid login is breaking skinning; but only on the login page. FireFox is reportingI am also seeing this exception in the server logsAfter login, it all seems to be OK. I am completely stumped as to what is wrong. My filter isn't very clever it's basically "If you did not request the login page and you do not appear to have a login - back to the login page you go"
Anyone any ideas?


SCJP6
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
Stepping through the code, it looks like the filter is picking up a lot of other requests (a4j stuff) and redirecting them to login.jsf as well; which would explain my problem I guess.

So how do I modify the filter so that is only fires for URIs the user has entered into their browser and not everything else? If someone going to "/application/x.jsf" without having a proper login, I want to force them back to "/application/login.jsf". I could change the initial "if" test tobut that does not feel right to me somehow.
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
One way of not filtering the a4j requests could be to place your custom filter entry above the richfaces filter entry in your web.xml.
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
Thanks Kavita, but it was already before the RichFaces filter. I tried moving to after just to see, but that had no effect either. The section from my web.xml looks like this Just a shame that there is no "<exclude-pattern/>", that would be perfect! When I decided to use a filter to stop people directly accessing pages without a login, I didn't consider that a4j would be making subsequent requests. Listing every page apart from login is ugly and brittle, but would work I guess.
Or I need to find another way to stop people accessing pages when they shouldn't.
Saikiran Madhavan
Greenhorn

Joined: May 15, 2006
Posts: 28
Hi Jason,

I am working on an application and where i exactly face the same issue as yours. We are getting some Syntax error javascript dialog whenever we reach our login page and the other pages are working fine. The below given is the code snippets for our application.
web.xml

TimeoutFilter.java


sessionTimeout.jsp

login.jsp

We have recently upgraded to JSF 1.2 and from that onwards we are getting this error.
We are using JBoss EAP 4.3/RichFaces 3.3.1/JDK 1.5/Spring/Hibernate

kindly let me know, how you solved your issue - also help us out from this issue.

Thanks
Saikiran
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
I fixed in what is rathr an ugly way IMHO. I just check to see what was being requested.

I am no expert with Faces, there's probably a much more elegant way to do it. For session timeout etc, I just used a HttpSessionListener.
Saikiran Madhavan
Greenhorn

Joined: May 15, 2006
Posts: 28
Jason,

Thanks for your reply. We too have solved the issue of us.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Odd problem with RichFaces and Servlet Filter
 
Similar Threads
Handling session timeout
Bacis doubt input property in struts-config.xml
NullPointerException in AutoScrollPhaseListener
Visual Web JSF Navigation... Help!
How to know login & logout status of user