• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter questions

 
stefania ferrarelli
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if I want to modify request parameters inside a filter is it right to set request attributes after modifying? Is it the only strategy or is there a better one?
If I have chained more than one filter for the same servlet or url the order of execution is that of filter tag regardless of the order of filter mapping?I tried to chain two filters but it is not exactly clear to me the order of execution(request, response, target servlet) - for instance when destroy() is called for each filter.It makes no difference using <servlet-name> instead of <url-pattern>?Apart from Compression Filter, could you suggest me another example of Wrapper?<dispatcher> INCLUDE, FORWARD, ERROR(how can I call an ERROR filter?) let other components of the application-instead of the client- to interact with the filter but if I have a RequestDispatcher.forward() to the first filter of a chain, also the following filters of the chain will have a FORWARD <dispatcher>?Can change the <dispatcher>inside a chain?Every kind of component can use a filter before it reaches a target servlet??The target must be a servlet, that is filters apply only to servlets?
Not very clear ideas about filters!!
Thanks
Stefania
 
stefania ferrarelli
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I tried the code of CompressionFilter of the HF book on page 722.On the Compression Filter method doFilter I get a NullPointerException on line

it can be ServletContext ctx or FilterConfig cfg, could you give me a suggestion?
Stefania
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3715
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filters can be applied to ...url patterns and/or servlet names. If multiple filters are specified for a url patter or a servlet name, they are invoked in the order they are specified in the DD.

Destroy is called when the filter is taken out of service (for example, when the web app is shutting down). It has nothing to do with request processing, just like init.

The target of a filter can be anything because a url pattern can point to anything...an image, html file, javascript file, jsp, and of course a servlet.

You might want to read the Filters chapter from Servlet Specification. It will clear all you doubts.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2345
90
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stefania,

Have a look at this old thread Compression-Filter-Head-First

You might get the answer for your NullPointerException there.

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic