From 46e6289bee1b034ee4fe13243fdcdef5e4283da1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 27 Apr 2012 16:41:59 +0200 Subject: [PATCH] Store servlet in servlet request, too. --- .../pterodactylus/demoscenemusic/core/TemplateServlet.java | 2 +- .../pterodactylus/demoscenemusic/page/ServletRequest.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java b/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java index 098cfba..9b09108 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java @@ -157,7 +157,7 @@ public class TemplateServlet extends HttpServlet { if (page != null) { ServletRequest servletRequest; try { - servletRequest = new ServletRequest(request); + servletRequest = new ServletRequest(request, this); } catch (URISyntaxException use1) { throw new IOException("Could not create URI from " + request.getRequestURI(), use1); } diff --git a/src/main/java/net/pterodactylus/demoscenemusic/page/ServletRequest.java b/src/main/java/net/pterodactylus/demoscenemusic/page/ServletRequest.java index 64e66c1..74d0450 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/page/ServletRequest.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/page/ServletRequest.java @@ -20,6 +20,7 @@ package net.pterodactylus.demoscenemusic.page; import java.net.URI; import java.net.URISyntaxException; +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import net.pterodactylus.util.web.Method; @@ -33,15 +34,17 @@ import net.pterodactylus.util.web.Request; public class ServletRequest extends Request { private final HttpServletRequest servletRequest; + private final HttpServlet servlet; /** * @param uri * @param method * @throws URISyntaxException */ - public ServletRequest(javax.servlet.http.HttpServletRequest servletRequest) throws URISyntaxException { + public ServletRequest(javax.servlet.http.HttpServletRequest servletRequest, HttpServlet servlet) throws URISyntaxException { super(new URI(servletRequest.getRequestURI()), Method.valueOf(servletRequest.getMethod().toUpperCase())); this.servletRequest = servletRequest; + this.servlet = servlet; } /** @@ -51,4 +54,11 @@ public class ServletRequest extends Request { return servletRequest; } + /** + * @return the servlet + */ + public HttpServlet getServlet() { + return servlet; + } + } -- 2.7.4