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 Sat, 22 Oct 2005 00:30:59 GMT
Hi Tim

Yes, as I described in one of my letters, I have used the
getRequestDispatcher, but when I do, images don't cache
in IE under https, no matter what I am forward'ing to or
include'ing to, whether it is in my web app context
or outside of it.  I have a META-INF/context.xml with
allowLinking="true", override="true".  I know
that the context.xml settings are effective
because both my own static image servlet and also
the DefaultServlet, when implicitly called via
getRequestDispatcher.forward(...) will display
the photos at the linked path, but they won't cache
effectively.   As I wrote earlier, I pretty much
copied all the DefaultServlet set header stuff and
the standard pub cache policy header stuff, plus
I overrode the getLastModifiedDate().

Note that these photos will cache with these mechanisms
under http, just not https.

Also note that the tomcat DefaultServlet WILL
cause IE to effectively cache images under both http
and https.   So Craig and Remy certainly did everything
right, insofar as the servlet spec goes...
It's just that I'm trying to play outside of the spec!

Maurice


Tim Funk wrote:
> Filters are only run on the incoming request. They can run on include() 
> and forward() to but you need to see configure that in web.xml.
> 
> If you are renaming the servlet path - you can't call chain.doFilter() 
> and get the results you expect. YOu need to get a new RequestDistpatcher 
> for the location your rewriting to and perform a forward()
> 
> -Tim
> 
> Maurice Yarrow wrote:
> 
>> 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
>>
>>
> 
> ---------------------------------------------------------------------
> 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