"lightbulb432" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> Could somebody explain when in the request process getLastModified is 
> called
> on a servlet? Is it before everything - all servlets, filters, listeners,
> anything else?
>

Of course, to be called at all, you need to be extending HttpServlet.  It is 
called after all filters, and most interesting listeners.  It is called from 
the service method of HttpServlet, so if you override that (e.g. you are a 
JSP page), then it won't be called at all.  It will be called just before 
the call to doGet.

> If you have multiple filters, how does this fit into the process - are 
> they
> all guaranteed to see the process through before the getLastModified call
> occurs on the servlet? (i.e. Can you count on the filtering to have 
> occurred
> before the code in your getLastModified runs?)
>

They can examine the header when the request returns to them (usually 
useless, since the response is usually committed by that time), or they can 
wrap the HttpServletResponse and override setStatus, setHeader, or 
setDateHeader as needed.  Otherwise, all filtering will have occurred before 
getLastModified is called.

> I ask in the case that your getLastModified is more than a simple file
> system last modified timestamp check, and where you're using some kind of
> controller servlet rather than servlet-per-path - in which case your one
> getLastModified method in the controller servlet could become complex,
> having to deal with multiple getLastModified semantics of multiple pages
> that map to one servlet?
>

The first servlet that implements getLastModified (and returns a date that 
value other than -1) wins for setting the Last-Modified header.  However, 
the first servlet that returns a date (other than -1) that is before the 
If-Modified-Since request header will force a 304 response, and the doGet 
method is never called (and, so, no other servlet in the chain is invoked).

So, in your case, the controller servlet should return -1 in the cases where 
it wants to delegate to the target servlet, and otherwise it gets to set the 
header.

> With what request methods is it called (GET, POST, etc...)? The servlet 
> spec
> gives only a slight indication that it's for GETs, but doesn't really
> elaborate.
>

It is only for GET and HEAD if you don't override the service method to do 
something else.

> Thanks.
> -- 
> View this message in context: 
> http://www.nabble.com/Filters-and-getLastModified-tf4006572.html#a11378442
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to