This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I wrote a simple request filter to check if the user is logged in before he can access any JSP page. I mapped the filter to the action servlet. Now the problem is that the filter works even when the login action is called. So it keeps directing the user to the login page. How do I prevent the filter from acting when the action is a login action ?
Hey dude. The problem is that your mapping for your filter is probably not optimally setup. Right now it sounds like you have the mapping set to run the filter on every page/action. For something like a login action, you probably want to make that a "public" action which can be run without the filter being run.
Post your mapping for the filter.
Joined: Jan 17, 2005
That makes sense, but how do you map the actions selectively ? I'm mapping to the action servlet itself. My filter mapping is as follows.
You have access to the request object in your filter code. Use the getRequestURL method to see if the URL in the request ends with "login.do". If it does, allow the request to pass without a valid login.