From: David ‘Bombe’ Roden Date: Fri, 27 Apr 2012 14:41:59 +0000 (+0200) Subject: Store servlet in servlet request, too. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=46e6289bee1b034ee4fe13243fdcdef5e4283da1;p=demoscenemusic.git Store servlet in servlet request, too. --- 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; + } + }