Arun Thomas wrote:
>
> Jody,
>
> The "Last-Modified" header is not a header in the request.  The HTTP/1.1
> spec identifies the various standard headers: "Last-modified" is neither a
> method of the request or the response.  You do find a "Last-modified" header
> associated with http entities which may or may not map to the entire
> response.
>
> It's easy to get confused as the request does have an "If-modified" header
> which requests that updated information only be sent if the server
> identifies the page as having been modified since the date provided in the
> request.  Otherwise, the browser will load from cache.  However, JSP pages,
> because they are usually dynamically generated, don't really respond well to
> this header (I suppose a clever server could do something useful with this,
> but I don't believe there are any that clever as of today.)
>
> As far as I know, there is no easy way to obtain this information (I'd be
> interested in any info other's can provide.)

You're correct about the headers; there's no way to find out when a JSP
page was last modified by looking at the headers.

But assuming that the JSP file is served from the file system (as opposed
to from a WAR file, or a database, or something else), you can use a
scriptlet like this get the information:

    <%
       String url = request.getServletPath();
       String fileName = application.getRealPath(url);
       java.io.File file = new java.io.File(fileName);
       java.util.Date lastModified = new java.util.Date(file.lastModified());
    %>
    <%= lastModified %>

It would be trivial to put this code in a custom tag instead to avoid
so much Java code in the page and also be able to easily display this info
in any page. I leave that as an exercise for the reader ;-)

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to