Filters process request objects before they get to the server or process response objects after they leave the server and before they are returned to the client. Filters can also be invoked in a chain so that one filter can pass the request or the response to another in the chain, and so on. You can use filters to do the following tasks:
The order and usage of filters are defined in the web application's configuration files and are not compiled into the web application itself. As a result, you can rearrange, add and remove filters without recompiling the application. This loose coupling of filters with web applications makes filters useful for many tasks by many members of a development team.
Specifically, filters are often implemented as:
When compiling filter examples in this chapter, you must include the jrun_root/lib/jrun.jar file in your classpath. For example:
>javac -classpath .;c:/jrun4/lib/jrun.jar *.java -d c:/jrun4/servers/default/deploy/default-app/web-inf/classes/
Most examples in this chapter extend the GenericFilter class to avoid having to override all methods of the Filter interface. For the GenericFilter code, see "Creating a generic filter class".
The default JRun server includes a filter that displays the total page execution time for every request. For more information, see "Viewing execution times".
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/jrun/4/Programmers_Guide/filters2.htm