aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Filter questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Filter questions" Watch "Filter questions" New topic
Author

Filter questions

stefania ferrarelli
Greenhorn

Joined: Jul 26, 2009
Posts: 29
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

Joined: Jul 26, 2009
Posts: 29
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

Joined: Sep 23, 2000
Posts: 3295
    
    7
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.

Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1675
    
  25

Hi Stefania,

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

You might get the answer for your NullPointerException there.

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filter questions