diff options
author | David A. Madore <david+git@madore.org> | 2014-10-07 14:38:33 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2014-10-07 14:38:33 +0200 |
commit | cfbf81150814c26e733480fa01a2eeb4541c068d (patch) | |
tree | c17f1340febd285ee72d429232f753418f744c2e /org/madore/damlengine | |
parent | 2b09cdd9abce74d1a3e51ed1d02447c8ca243851 (diff) | |
download | damlengine-cfbf81150814c26e733480fa01a2eeb4541c068d.tar.gz damlengine-cfbf81150814c26e733480fa01a2eeb4541c068d.tar.bz2 damlengine-cfbf81150814c26e733480fa01a2eeb4541c068d.zip |
WeblogServlet: Take an entry number as input (request path).
Diffstat (limited to 'org/madore/damlengine')
-rw-r--r-- | org/madore/damlengine/WeblogServlet.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/org/madore/damlengine/WeblogServlet.java b/org/madore/damlengine/WeblogServlet.java index 4baf055..f9d23e3 100644 --- a/org/madore/damlengine/WeblogServlet.java +++ b/org/madore/damlengine/WeblogServlet.java @@ -1,5 +1,7 @@ package org.madore.damlengine; +import java.util.regex.Pattern; +import java.util.regex.Matcher; import java.util.Properties; import java.util.Enumeration; import java.io.IOException; @@ -58,10 +60,20 @@ public class WeblogServlet extends HttpServlet { HttpServletResponse response) throws IOException, ServletException { + Matcher matcher; + int number = -1; + if ( (matcher=Pattern.compile("/(\\d{1,7})").matcher(request.getPathInfo())).matches() ) { + try { + number = Integer.parseInt(matcher.group(1)); + } catch (NumberFormatException e) { } + } + if ( number == -1 ) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } response.setContentType("text/html; charset=utf-8"); response.setCharacterEncoding("UTF-8"); OutputStream out = response.getOutputStream(); - final int number = 1729; try { WeblogSelect.fullProcess(new Context.WeblogSingleSelectionContext(number), out); |