From 827925b57dc5ba84e480cf9c66ff2cb13a096780 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Thu, 9 Oct 2014 20:02:12 +0200 Subject: Make up my mind as to what URLs should look like. --- org/madore/damlengine/WeblogServlet.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'org/madore/damlengine') diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java index d3b2523..2722616 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 = 2014100704L; + private static final long serialVersionUID = 2014100901L; @Override public void init(ServletConfig cfg) @@ -65,18 +65,21 @@ public class WeblogServlet extends HttpServlet { Matcher matcher; if ( pathInfo == null ) return new NoSuchPath(); - if ( (matcher=Pattern.compile("/(\\d{1,7})").matcher(pathInfo)).matches() ) { + if ( (matcher=Pattern.compile("/d\\.(\\d{4}-\\d{2}-\\d{2})\\.(\\d{4})\\.html").matcher(pathInfo)).matches() ) { + final String date; final int number; try { - number = Integer.parseInt(matcher.group(1)); + date = matcher.group(1); + number = Integer.parseInt(matcher.group(2)); } catch (NumberFormatException e) { return new NoSuchPath(); } try { final Connection conn = WeblogDatabaseConnection.getConnection(); final PreparedStatement selSt - = conn.prepareStatement("SELECT id , extract(epoch from mdate) FROM entries WHERE id=?"); - selSt.setInt(1,number); + = conn.prepareStatement("SELECT id , extract(epoch from mdate) FROM entries WHERE edate=? AND id=?"); + selSt.setString(1,date); + selSt.setInt(2,number); final ResultSet selRes = selSt.executeQuery(); if ( selRes.next() ) { int id = selRes.getInt(1); -- cgit v1.2.3