Craig R. McClanahan wrote:
>
>Geoff, I haven't used getLastModified() a lot -- it's pretty useless for
100%
>dynamic content -- but it seems to do what I wanted when I used it.  See
>further comments below.

Yes, exactly. Here's my reasoning that follows from this...

1) getLastModified is pretty useless for dynamic content and
2) servlet engines usually include a FileServlet that's perfect for
delivering static content :-) (and even that probably overrides service()
rather than using getLM()), thus
3) getLastModified() is effectively useless in most situations, and it
should be deprecated, and
4) if we want to support this functionality in the servlet api we ought to
design a more _functional_ replacement.

>> here's a copy of the relevant stuff I sent to the API feedback...
>>
>> 1) it doesn't allow you to easily share state with doGet(), which you
almost
>> always want to do
>
>Because getLastModified() -- getLM for short -- is passed the incoming
request,
>it has access to all of the attributes of that request (the request URI and
>other request properties, the HTTP headers, included cookies, and the
user's
>session if there is one).  The session can be the key to sharing things if
your
>needs go beyond the parameters of the individual request.  You can have the
>servlet that generates the actual content store things useful in making
>subsequent getLM calls run faster.  Likewise, you can also have getLM store
>things in the session for later use in the doGet call, if they are
expensive to
>calculate.
>
>Of course, if you're not using sessions, there isn't the opportunity to do
>this.

Yes, you could do this, although considering the high level of binding
between getLM() and doGet(), this seems overkill to have to use the session
to communicate. I wouldn't consider the use of the session in this case
'easy' - although I'd be prepared to accept 'standard' ;-)

>> 2) there's no easy way co-ordinate error handling between getLM() and
>> doGet() (you can't even throw a ServletException from getLM()).
>
>If I suspect there is a problem, or run into difficulties calculating the
>timestamp to return, I return -1 from getLM and let doGet() deal with it.

Why not just abandon getLM() and do it all in doGet() then? Otherwise you
are duplicating effort...

>> 3) getLM() will set LastModified even if doGet() fails and throws an
>> exception. This means that the client will try and cache your "error"
page
>> (unless you do a sendError() or somesuch).
>
>I have found this to be true with static HTML pages as well.  Have you ever
>pressed STOP during a long page display (in Netscape Navigator), see the
>"Transfer Interrupted" message, and you can't get rid of it, even by
pressing
>Reload?  The last time I looked at this, I concluded it had to be based on
>conditional GET responses because I've got Netscape configured to check for
>updates "once per session".

I hadn't though of that, but a dynamic page is a lot more likely to fail
than a static one.. ;-)

>> I suggested that making the logic in gLM() available to be called from
>> _within_ doGet() would be much more useful in general.
>
>Given that the service() method needs to call getLastModified() before
calling
>doGet() -- to decide whether to send a NOT MODIFIED response back -- that
would
>seem to defeat the purpose.

I think maybe I didn't explain that one very clearly. I was thinking of
deprecating the old gLM() and having a an alternative like a helper method
you could call inside doGet() to encapsulate the header name, etc. Or like a
callback interface or something. I dunno, there must be a better way to do
it! :-)

Geoff

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to