tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Yarrow <>
Subject Re: hacking the tomcat DefaultServlet
Date Fri, 21 Oct 2005 18:47:40 GMT
Hello Tomcat users

I am attempting to use a Filter to first modify
a portion of the incoming URL (request.getServletPath())
and next, to send this filtered request on to the
tomcat DefaultServlet.  The filter is indeed called
and I am able to complete the first goal of modifying
the incoming URL.  I then used a Decorater pattern by
sub-classing HttpServletRequestWrapper and override
the getPathInfo() method because tomcat's
DefaultServlet calls this method out of its
getRelativePath method.  I also set the following
attributes because the DefaultServlet.getRelativePath()
also looks at an attribute named
"javax.servlet.include.request_uri", as well as two others,
all of which I set to the modified URL path in my wrapper
class.  I then  filterChain.doFilter(myReqWrapper, res);
to pass this wrapped req obj to DefaultServlet.

However, the DefaultServlet does not seem to be called.

Here are the filter config mappings which I placed in
my web apps web.xml before the servlet mappings:

<!-- the filter -->

<!-- incoming: what the filter sees -->

<!-- outgoing: where the filter passes to -->

For the outgoing, I also tried:


But I still was unable to get the request passed to the
tomcat DefaultServlet.

Does anyone see what I am doing wrong?

(I can send additional pieces of the relevant code,
if anyone would like to see that also, so please do not
hesitate to ask.)

Maurice Yarrow

Tim Funk wrote:
> I think this should work in your own web.xml:
> <filter-mapping>
>   <filter-name>MyFilter</filter-name>
>   <servlet-name>default</servlet-name>
> </filter-mapping>
> -Tim
> Maurice Yarrow wrote:
>> Tim
>> So, my question is: can I request that a filter be applied to all
>> static page requests that are going to DefaultServlet?  Or is this
>> done with a Valve?
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message