I cud write a filters without any difficult, when doing something on request. If I need to write something for response, then there are some more additional tasks I need to do. Being a lazy fundoo, I just stopped with reading, have not implemented it anywhere. Luckily I got an opportunity to implement in our own product itself.
please have a look at http://www.orionserver.com/tutorials/filters/3.html for a response filter. A structured way of explaining the concept.
Filters generally applied to corresponding requests. But when the request is forwarded from one servlet to another source, that will not be processed with Filter. (I checked with Tomcat 4.1). We need to add some more parameters with Filter mapping as noted below.
<filter-mapping> <filter-name>VJFilterTest</filter-name> <!–<servlet-name>VJServlet</servlet-name>–> <url-pattern>/servlet/MyTest</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> — ————————————————— *Free* software is a matter of liberty not price. You should think of “free” as in “free speech”.