Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter Query

 
Manish Agarwal
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have these three files:

//Source Servlet: Source.java


//Destination Servlet: Destination.java


//Filter ParamAdder : ParamAdder.java



//web.xml



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,
 
Anupama Ponnapalli
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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-mapping>
<filter-name> ... </filter-name>
<url-pattern> ... </url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

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!

Cheers,
Anu
[ April 13, 2007: Message edited by: Anupama Ponnapalli ]
 
Manish Agarwal
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Anupama, that clears the doubt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic