From 1fa9c99c4c069ef395bd9562c2aa817bfc656f09 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 7 Oct 2014 16:15:16 +0200 Subject: Take into account last modified time of Java class itself. (This is really unsatisfactory, but can I do better?) --- org/madore/damlengine/WeblogServlet.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java index 568a9ec..d3b2523 100644 --- a/org/madore/damlengine/WeblogServlet.java +++ b/org/madore/damlengine/WeblogServlet.java @@ -34,7 +34,7 @@ import javax.servlet.http.HttpServletResponse; public class WeblogServlet extends HttpServlet { - private static final long serialVersionUID = 2014100703L; + private static final long serialVersionUID = 2014100704L; @Override public void init(ServletConfig cfg) @@ -83,8 +83,18 @@ public class WeblogServlet extends HttpServlet { double mdate = selRes.getDouble(2); if ( id != number ) throw new ServletException("this cannot happen"); - long lastModified = ((long)mdate)*1000; - // O'Reilly recommends not using milliseconds part. + long lastModified = (long)(mdate*1000); + long thisLastModified; + try { + // Attempts to detect when *this* class was last modified. + thisLastModified = WeblogServlet.class.getResource("WeblogServlet.class").openConnection().getLastModified(); + } catch (Exception e) { + thisLastModified = 0; + } + if ( thisLastModified > lastModified ) + lastModified = thisLastModified; + // O'Reilly recommends not using milliseconds part: + lastModified = (lastModified/1000)*1000; return new SingleBlogEntryPath(number, lastModified); } else return new NoSuchPath(); -- cgit v1.2.3