• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Filtering All Actions *Except* One

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use a filter init parameter.
 
reply
    Bookmark Topic Watch Topic
  • New Topic