Well, simply inserting a "getLastModified()" method into the generated
servlet will not work due to the class inheritance involved.
With standard (non-JSP generated) servlets, the "service()" method in
HttpServlet calls "getLastModified()". With JSP-based servlets,
HttpServlet's "service()" method has been overriden by Tomcat (i.e.,
Catalina stuff) so the call to "getLastModified()" does not occur.
Still, it might be possible to hack the JSP-based servlet....I hate to hack
though....
I'll think about it. Thanks for the suggestion.
Tony
----- Original Message -----
From: "Markus Kirsten" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, June 04, 2002 5:16 AM
Subject: Re: ??? Using JSPs to Send Not-Modified-Since Header ???
> Hi Tony,
> Isn't it possible to put in the method after the jsp file has been
> rewritten (by Tomcat) to a standard java source code file? Maybe it's
> quick and dirty but I can't see why it shouldn't work.
>
> Best of luck!
>
>
> Markus
>
> On Tuesday, June 4, 2002, at 09:28 AM, Tony LaPaso wrote:
>
> > Hi all,
> >
> > In looking at past posts, I'm afraid I know the horrible answer
> > to this issue but I thought I'd ask just in case I missed
> > anything.
> >
> > Let me start by saying I'm using Tomcat v4.0.4 beta 3.
> >
> > As you know, when a client (usually a web browser) has a cached
> > version of a resource (usually a web page) it can send an
> > "If-Modified-Since" header to the HTTP server. The server
> > compares the time/date stamp specified in the header with that of
> > the requested resource. If the resource has *not* been modified
> > since the time specified in the "If-Modified-Since" header, the
> > server sends back a 304 (Not-Modified) response, effectively
> > telling the client (usually a web browser) that its cached
> > version of the resource is still valid.
> >
> > When writing a servlet, it's easy to handle this sort of
> > scenario. The javax.servlet.http.HttpServlet class has a
> > "service()" method. This method first checks if the incoming HTTP
> > method is a GET. If it is, the "service()" method proceeds to
> > call the "getLastModified()" method of the servlet. As a
> > developer, you can override "getLastModified()" to return a long
> > value representing the last time the requested resource was
> > changed. Depending on the value returned by "getLastModified()"
> > (note that -1 is returned if you don't override the method) the
> > "service()" method may simply return a 304, Not-Modified response
> > rather than calling the servlet's "doGet()" method.
> >
> > Now, the $18.32 Question: How do you ensure "getLastModified()"
> > is called in JSP?
> >
> > No, you cannot simply do this:
> >
> > <%!
> > public long getLastModified() {
> > return xxx;
> > }
> > %>
> >
> > The problem is that the above method will never be called by the
> > container.
> >
> > I traced through some of the Tomcat/Catalina/Jasper code and it
> > seems to me that the response code is being set to 200/OK very
> > early on in the processing.
> >
> > I also took a cursory look at the JSP spec and didn't find any
> > indication of setting a "Not-Modified" response code...so, I am
> > thinking this is something that is (strangely) missing in the JSP
> > specification. I have a JSP page that needs to update itself once
> > per day. Therefore, it would be very handy to have the
> > "getLastModified()" functionality enjoyed by servlet writers.
> >
> > Can anyone confirm this?
> >
> > Thanks...
> >
> >
> > --
> > To unsubscribe, e-mail: <mailto:tomcat-user-
> > [EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:tomcat-user-
> > [EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>