After reading it, i'm still confused and not too understand about it..
do you often use getLastModified in your application?..
Would you like to give me a snippet code which implemented in real world?...
yap.. i thought it's senseless.. it just used for simplify my comprehension..
would you like to give any code how to implement getLastModified in 'real-world'?...
Sorry for my foolish, i'll learn hard..
Thanks in advance..
Author and all-around good cowpoke
Joined: Mar 22, 2000
From HTTP 1.1 header definitions:
The Last-Modified entity-header field indicates the date and time at which the origin server believes the variant was last modified.
Last-Modified = "Last-Modified" ":" HTTP-date
An example of its use is
Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
The exact meaning of this header field depends on the implementation of the origin server and the nature of the original resource. For files, it may be just the file system last-modified time. For entities with dynamically included parts, it may be the most recent of the set of last-modify times for its component parts. For database gateways, it may be the last-update time stamp of the record. For virtual objects, it may be the last time the internal state changed.
An origin server MUST NOT send a Last-Modified date which is later than the server's time of message origination. In such cases, where the resource's last modification would indicate some time in the future, the server MUST replace that date with the message origination date.
An origin server SHOULD obtain the Last-Modified value of the entity as close as possible to the time that it generates the Date value of its response. This allows a recipient to make an accurate assessment of the entity's modification time, especially if the entity changes near the time that the response is generated.
HTTP/1.1 servers SHOULD send Last-Modified whenever feasible.
So - the programmer's task is to set a response header with correctly formatted date.
You could have the Hello servlet code create a String variable with the formatted date/time when it is first initialized and use the addHeader method in HttpServletResponse interface to set the header using that string for every response.
You could keep the long (milliseconds) value from a call to the System.currentTimeMillis() method and use the addDateHeader method which should format the date correctly.