diff options
author | David A. Madore <david+git@madore.org> | 2014-10-07 16:15:16 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2014-10-07 16:15:31 +0200 |
commit | 1fa9c99c4c069ef395bd9562c2aa817bfc656f09 (patch) | |
tree | 2e3a8130f1621ed8b10dc4a548309c8b2051d354 | |
parent | 1b5c19b3e42f4549ebb863cd97d2656e833ce516 (diff) | |
download | damlengine-1fa9c99c4c069ef395bd9562c2aa817bfc656f09.tar.gz damlengine-1fa9c99c4c069ef395bd9562c2aa817bfc656f09.tar.bz2 damlengine-1fa9c99c4c069ef395bd9562c2aa817bfc656f09.zip |
Take into account last modified time of Java class itself.
(This is really unsatisfactory, but can I do better?)
-rw-r--r-- | org/madore/damlengine/WeblogServlet.java | 16 |
1 files 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(); |