Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filtering All Actions *Except* One

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run into a situation in which I'd like to apply a filter to all *.do actions except one. Is there any way to do that short of adding every action as a URL mapping to the deployment descriptor.

For my particular case, I require that the user select the site he/she would like to administer before using my application. To do that, they go through an action called "setupsiteselection.do". I've created a Filter that will check to see if a site identifier is stored in the session or not. If it isn't, the user is redirected so that he/she selects a site before accessing the page. If it's there, the user simply goes on.

I want this filter to be applied to most of my JSP's and all of the actions except for the one I indicated previously. The JSP's aren't an issue - it's the actions that are giving me a headache. Anyone know of a good way to get around this - I don't want to add every individual action to the URL Mappings as there are dozens of actions in the application.

Thanks,
Corey
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Corey,
I would handle that by having the filter get called for all *.do actions. Then the filter can check the path and see if it was the one admin/setup action.

While I generally try to avoid referencing the path from the action, I think it outweighs the risk of forgetting to add an action to the filter later.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
I would handle that by having the filter get called for all *.do actions. Then the filter can check the path and see if it was the one admin/setup action.


Thanks, Jeanne. That's the solution I had come up with and implemented, but I didn't really like putting the path into the filter code. It works, but I was wondering if someone had a better approach. That doesn't seem to be the case.

Thanks.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a filter init parameter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic