On Wed, 25 Apr 2001 [EMAIL PROTECTED] wrote:

> this is kind of unrelated, but sort of related...
> 
> will a filter only be used once per request?  for example, if i have a filter
> mapped to /*, then from a servlet, i forward to another servlet or to a jsp,
> will the filter be run twice, or just once?
> 

That question has been an "item of interest" for the JSR-053 expert group
that defines the servlet and JSP specs, because you can make arguments for
either approach.  The current answer (and what Tomcat 4.0 currently
implements) is that filters only apply on the original request -- they do
not get invoked when a servlet or JSP page is accessed through a
RequestDispatcher.

> thanks.
> 

Craig


> 
> > -----Original Message-----
> > From: Bob Jamison [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, April 25, 2001 9:14 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Future of Filter?
> > 
> > 
> > Amy Roh wrote:
> > 
> > > Servlet spec 2.3 has changed to support init(FilterConfig 
> > config) and
> > > destroy() methods instead of getFilterConfig() and
> > > setFilterConfig(FilterConfig config) after discussion to 
> > change filter cycle
> > > to be similar to the servlet life cycle in the expert 
> > group.  The recent
> > > changes will be reflected in the new Proposed Final Draft 2 
> > (which will be
> > > available to public very soon).  So TC4 is up to date with 
> > the recent spec.
> > > :-)
> > > 
> > > Amy
> > > 
> > Thanks, that's what I suspected.
> > 
> > By the way, I did not find any examples that actually performed any
> > filtering.  Would this be a common usage pattern for Filter?  :
> > 
> > 
> > 
> > 
> > ==== SNIP ====
> > 
> > public class MyFilter implements Filter
> > {
> > 
> > //---An inner class wrapper that does my filtering
> > class MyServletResponse extends ServletResponseWrapper
> > {
> >   public MyServletResponse(ServletResponse response)
> >   {
> >    super(response);
> >    //do stuff
> >   }
> > }
> > //---end inner class
> > 
> > 
> > 
> > public void doFilter(ServletRequest request,
> >                      ServletResponse response,
> >                      FilterChain chain)
> >                   throws IOException,ServletException
> > {
> >   MyServletResponse altResponse = new MyServletResponse(response);
> >   chain.doFilter(request,altResponse);
> > }
> > 
> > }
> > 
> > ==== UN-SNIP ====
> > 
> > 
> > 
> > 
> > Something like that, maybe?
> > 
> > 
> > 
> > Anyway, thanks again.
> > 
> > Bob
> 

Reply via email to