diff options
Diffstat (limited to 'jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java')
-rw-r--r-- | jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java index 6aede63657..2ec9d9c5bd 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherTest.java @@ -105,6 +105,27 @@ public class DispatcherTest assertEquals(expected, responses); } + + @Test + public void testForwardWithParam() throws Exception + { + _contextHandler.addServlet(ForwardServlet.class, "/ForwardServlet/*"); + _contextHandler.addServlet(EchoURIServlet.class, "/EchoURI/*"); + + String expected= + "HTTP/1.1 200 OK\r\n"+ + "Content-Type: text/plain\r\n"+ + "Content-Length: 54\r\n"+ + "\r\n"+ + "/context\r\n"+ + "/EchoURI\r\n"+ + "/x x\r\n"+ + "/context/EchoURI/x%20x;a=1\r\n"; + + String responses = _connector.getResponses("GET /context/ForwardServlet;ignore=true?do=req.echo&uri=EchoURI%2Fx%2520x%3Ba=1%3Fb=2 HTTP/1.1\n" + "Host: localhost\n\n"); + + assertEquals(expected, responses); + } @Test public void testInclude() throws Exception @@ -279,6 +300,10 @@ public class DispatcherTest dispatcher = getServletContext().getRequestDispatcher("/AssertIncludeForwardServlet/assertpath?do=end"); else if(request.getParameter("do").equals("assertforward")) dispatcher = getServletContext().getRequestDispatcher("/AssertForwardServlet?do=end&do=the"); + else if(request.getParameter("do").equals("ctx.echo")) + dispatcher = getServletContext().getRequestDispatcher(request.getParameter("uri")); + else if(request.getParameter("do").equals("req.echo")) + dispatcher = request.getRequestDispatcher(request.getParameter("uri")); dispatcher.forward(request, response); } } @@ -462,6 +487,19 @@ public class DispatcherTest } } + public static class EchoURIServlet extends HttpServlet implements Servlet + { + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException + { + response.setContentType("text/plain"); + response.setStatus(HttpServletResponse.SC_OK); + response.getOutputStream().println(request.getContextPath()); + response.getOutputStream().println(request.getServletPath()); + response.getOutputStream().println(request.getPathInfo()); + response.getOutputStream().println(request.getRequestURI()); + } + } + public static class AssertForwardServlet extends HttpServlet implements Servlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException |