Java Servlets - Support for Filters

Filters and Servlet Chaining (Beta)
Documentation
Filters and Servlet chaining
In the Java Web Server, filtering support is provided by the ability
to flexibly chain servlets based on mime type. Both local and remote
servlets can be part of the chain. Filtering is yet another way to load
and invoke servlets in the Java Web Server. The sections below
describe servlet chaining in more detail.
Mime types and Servlets
The Java Server provides a great deal of flexibility in how Servlets can be
invoked. One way of invoking servlets is by associating a Servlet with a
particular mime-type such that the servlet so configured is invoked each time
a response with the corresponding mime-type is generated.
When a servlet writes to the OutputStream for the first
time, the mime-type is checked. If there is a servlet configured for this
particular mime-type, then the OutputStream of the response is piped
to the InputStream of the Servlet. So the second servlet's request stream
is essentially a pipe from the first servlet's response stream. Multiple
such servlets can be chained together.
How to configure a servlet chain
In Beta, there is no admin GUI support for servlet chaining. So the
administrator has to manually edit the mimeservlets.properties file. This
file resides in the directory
<service_root>/admin/properties/process/javawebserver/webpageservice/
This file maps mime types to servlet names. Servlet names are mapped to actual
classes using the servlets section of the admin tool. This flexible approach
means that some of the servlets in the servlet chain can actually be configured
to be remote servlets. In the case of remote servlets in the chain, they are
brought over before being invoked.
Triggering Filter Chains
When servlets generate responses, they set the mime type of the response. When a
particular mime type is configured to invoke
another servlet in the mimeservlets.properties file, the filter chain
is triggered. The servlets that get invoked
in the chain have their request inputs be the outputs of the previous member
in the chain.
All servlets, excepting the first one in the chain returns the string "FILTER" as
the name of the http method (i.e when HttpRequest.getMethod() is called).
Enabling Filters
In the
<service_root>/admin/properties/process/javawebserver/webpageservice/httpd.properties:
file set
enable.filters=true
Top
java-server-feedback@java.sun.com