As Joe pointed out, there is no problem using filters with Struts. As Joe also pointed out, generally speaking, getting a filter to fire for a specific Action, or group of Actions, is problematic. Struts 1.3, as Joe yet again pointed out, is a nice solution for this (Joe has been busy! LOL)
However, even with Struts 1.3, or WebWork, etc., it's still part of the request handling cycle of the framework (modifying the request chain in Struts or an interceptor stack in WW I mean). Now, this might be exactly what you want, and in many cases it certainly will be, but a filter is nice because it sits outside the framework and can process before or after the framework is involved. In some cases, *this* is really what you want. If you do decide a filter is the way to go and you still need more fine-grained control over when they fire, it might be helpful to look at the filters in Java Web Parts (http://javawebparts.sourceforge.net). Not so much because they may do what you need, but more because they all support two init parameters, pathSpec and pathList, which combined allows you much more control over what URIs trigger them. More importantly, they make use of a FilterHelpers class, which you could use from your own filters. Basically, you would read in those parameters in your filter's init(), then in doFilter() you do: if (FilterHelpers.filterPath(request, pathList, pathSpec)) { ...and then do whatever the filter does. So, the filter only fires when the path matches one of the items in pathList (or, conversely, you can set pathSpec to EXCLUDE the paths in pathList, whichever is easier). And, the pathList supports wildcards, but you can get as specific as you like, down to exact URIs if you wish. HTH. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Fri, March 10, 2006 8:55 am, starki78 said: > Yes I also come to the conclusion that it doesn't fit optimally, > but it's always worth making such considerations to come to new solutions! > > Thanks for your input > Starky > > > > > ---------- Initial Header ----------- > >>From : "Joe Germuska" [EMAIL PROTECTED] > To : "starki78" [EMAIL PROTECTED],"user" user@struts.apache.org > Cc : > Date : Fri, 10 Mar 2006 07:25:33 -0600 > Subject : Re: Using Filters with Struts? > > > > > > > >> At 8:23 AM +0100 3/10/06, starki78 wrote: >> >Hi I made thoughts about filters >> >(javax.servlet.Filter) >> >e.g. use them for logging >> >and performance measuring purposes. >> >Now as we are using struts I would like >> >to know if you can, and if it makes >> >sense to assign a filter to an action. >> >Can someone help me understand if this might >> >be a good solution? >> >> You can certainly use servlet filters with Struts. It would be hard >> to apply a filter to a specific action, since the filters operate >> before-and-after Struts but not during the execution. I suppose you >> might have the filter set a request attribute and then have an Action >> look for it, but that seems tangled and suboptimal. >> >> I suppose in the end it depends on what you're trying to do. >> >> Joe >> >> -- >> Joe Germuska >> [EMAIL PROTECTED] * http://blog.germuska.com >> >> "You really can't burn anything out by trying something new, and >> even if you can burn it out, it can be fixed. Try something new." >> -- Robert Moog >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]