File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Filter Query 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 Query" Watch "Filter Query" New topic

Filter Query

Manish Agarwal
Ranch Hand

Joined: Jun 22, 2004
Posts: 34
Hi All,

I have these three files:

//Source Servlet:

//Destination Servlet:

//Filter ParamAdder :


I am getting the output as "filterAdded :null ".I can't understand even after setting the request attribute in the Filter, it is giving null in the output.

Please help.


Thanks and Regards,<br />Manish Agarwal<br />SCJP 1.4 (100%)<br />SCWCD 1.4 (98%)<br />SCBCD 1.3 (Preparing)
Anupama Ponnapalli
Ranch Hand

Joined: Jun 12, 2006
Posts: 66

The filter-mapping web.xml entry takes another child element, called Dispatcher. It can have 4 possible values: REQUEST, INCLUDE, FORWARD and ERROR. This determines the type of requests handled by the filter.

If this child element is missing, the default value is REQUEST. So, if your filter used Source as the servlet, it would work.

For destination, try this:

<filter-name> ... </filter-name>
<url-pattern> ... </url-pattern>

By the way, you can have upto 4 dispatcher elements, so you could very well write a mapping that ensures that all requests types are handled by the filter!

[ April 13, 2007: Message edited by: Anupama Ponnapalli ]
Manish Agarwal
Ranch Hand

Joined: Jun 22, 2004
Posts: 34
Thanks Anupama, that clears the doubt.
I agree. Here's the link:
subject: Filter Query
It's not a secret anymore!