From cfbf81150814c26e733480fa01a2eeb4541c068d Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 7 Oct 2014 14:38:33 +0200 Subject: WeblogServlet: Take an entry number as input (request path). --- org/madore/damlengine/WeblogServlet.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'org/madore/damlengine') 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); -- cgit v1.2.3