velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Not understanding something
Date Thu, 26 Jun 2008 13:01:11 GMT
John,

johne wrote:
> I had recently upgraded to Tomcat 6 and am using the following on each of my
> filter mappings (I have several chained filters).  It is the first time I
> had chosen to use this, so maybe I am doing something wrong.
> 
>     <filter-mapping>
>         <filter-name>User Agent Filter</filter-name>
>         <url-pattern>/*</url-pattern>
>         <dispatcher>REQUEST</dispatcher>
>         <dispatcher>FORWARD</dispatcher>
>     </filter-mapping>

This configures the filter to run on every request that is either the 
original request (REQUEST) or a forwarded request (FORWARD) from 
RequestDispatcher.forward(). That means it will /not/ run when 
RequestDispatcher.include() is used, for example.

> Would this allow the search engine to see the *.vm somehow?

I'm not sure what you mean by "see the *.vm". Do you mean "can a crawler 
request the .vm file directly"? That depends on your server 
configuration. Can /you/ request the .vm directly? If so, then the 
crawler can, too (although it probably won't, given that it probably 
doesn't know the paths to any of the templates).

I suspect that when RequestDispatcher.forward() is called, the original 
request is used (plus a ver bits of info -- I'll get to those later) and 
the same headers are available -- such as the User-Agent. In this case, 
your User Agent Filter intercepts the request and logs a request for 
that resource.

During a forward, the container should set the following request attributes:

javax.servlet.forward.request_uri
javax.servlet.forward.context_path
javax.servlet.forward.servlet_path
javax.servlet.forward.path_info
javax.servlet.forward.query_string

These attributes contain the original values for each attribute (for 
instance, /foo forwarding to /bar would have "/foo" as the value for 
javax.servlet.forward.request_uri). See section 8.4.2 of the servlet 
specification (and section 8.3.1 for includes) for more details.

You should have your filter check to see if those values match the 
request you /think/ you are processing. I suspect that the User Agent 
here is not actually requesting those resources... it's a forward or an 
include that is being handled by your filter as if it were the original 
request.

-chris


Mime
View raw message