I believe the new Servlet API2.3 has a filtering mechanism for this
functionality.
from
http://developer.java.sun.com/developer/technicalArticles/Servlets/servletap
i2.3/
<snippet>
Filters
The most significant part of API 2.3 is the addition of filters -- objects
that can transform a request or modify a response. Filters are not servlets;
they do not actually create a response. They are preprocessors of the
request before it reaches a servlet, and/or postprocessors of the response
leaving a servlet. In a sense, filters are a mature version of the old
"servlet chaining" concept. A filter can:
-Intercept a servlet's invocation before the servlet is called
-Examine a request before a servlet is called
-Modify the request headers and request data by providing a customized
version of the request object that wraps the real request
-Modify the response headers and response data by providing a customized
version of the response object that wraps the real response
-Intercept a servlet's invocation after the servlet is called
You can configure a filter to act on a servlet or group of servlets; that
servlet or group can be filtered by zero or more filters. Practical filter
ideas include authentication filters, logging and auditing filters, image
conversion filters, data compression filters, encryption filters, tokenizing
filters, filters that trigger resource access events, XSLT filters that
transform XML content, or MIME-type chain filters (just like servlet
chaining).
</snippet>
HTH,
Robert
> -----Original Message-----
> From: Payam Mirrashidi [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 05, 2001 11:09 PM
> To: [EMAIL PROTECTED]
> Subject: intercepting requests
>
>
>
> What mechanism should be used to intercept all requests in a struts
> application? I'm looking for something similar to a Tomcat
> RequestInterceptor but applicable only to a specific
> ServletContext. I want
> to be able to do some housekeeping before the first call to
> servlet.service() for that request. That is, I want to insert some logic
> before any of my business logic is called, be it in the form of an
> ActionForm, an Action, a servlet or just a .jsp page.
>
> Specifically, what I'm trying to do is to insert some global sanity checks
> on the request before any ActionForm validate() methods are called. Of
> course, I want the same checks performed before any .jsp rendering or any
> servlet.service() calls. One way to do this would be to subclass
> ActionServlet and insert some checks there and also have all .jsps and
> servlets call that same code before doing anything.
>
> Is there a better way? Ideally, I wouldn't have to manually have
> to add all
> the calls to the sanity checker.
>
> ----
> Payam Mirrashidi
> [EMAIL PROTECTED]
>
>
>
>
>