Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Struts and the fly likes Chaining filter servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Chaining filter servlet" Watch "Chaining filter servlet" New topic

Chaining filter servlet

Funicelli Aldo

Joined: Jan 08, 2003
Posts: 12
I all
I need to log all post parameter inside a db table. I create for this a Filter Servlet with jsp mapping. The problem is that this servlet is called after the Action class tha handle the post action.

Inside Filter Servlet, when I use the code
Enumeration enumPostData = httpRequest.getParameterNames();
Enumeration is empty, because Action class forward the request using the parameter "redirect=true".

This is part of struts-config:
<action name="autocarro000" type="it.genialloyd.autocarro.ProcessaAutocarro000" validate="false" input="/autocarro/autocarro000.jsp" scope="session" path="/processaAutocarro000">
<forward name="autocarro040" path="/do/preparaAutocarro040" redirect="true" />

This is web.xml:


Is it possible to invoke Filter class (statistichePagina) before the ActionServlet of struts?
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Instead of making the filter intercept the request before it goes to a jsp, you could map the filter to intercept all requests to the action servlet. In this way it will be called before the action servlet and action classes.

Note however that when you do action-action forwarding you will probably be logging the same post parameters again. Just check if that happens, I suppose it should, not sure though.

Also ensure that the filter is only a pre-processing filter and not a post-processing filter, otherwise you might face errors when forwarding requests to another action.

Sheldon Fernandes
Have you tried LearnNowOnline?
subject: Chaining filter servlet