tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Yarrow <yar...@best.com>
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 -->
<filter>
   <filter-name>ImageRequestFilter</filter-name>
   <filter-class>getimg.servlets.ImageRequestFilter</filter-class>
</filter>

<!-- incoming: what the filter sees -->
<filter-mapping>
   <filter-name>ImageRequestFilter</filter-name>
   <url-pattern>/ImageRequest/*</url-pattern>
</filter-mapping>

<!-- outgoing: where the filter passes to -->
<filter-mapping>
   <filter-name>ImageRequestFilter</filter-name>
   <servlet-name>default</servlet-name>
</filter-mapping>

For the outgoing, I also tried:

<filter-mapping>
   <filter-name>ImageRequestFilter</filter-name> 
<servlet-name>org.apache.catalina.servlets.DefaultServlet</servlet-name>
</filter-mapping>

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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message