diff --git a/apache-jsp/pom.xml b/apache-jsp/pom.xml
index 89ed1724da0..cc76dfc7edd 100644
--- a/apache-jsp/pom.xml
+++ b/apache-jsp/pom.xml
@@ -69,11 +69,6 @@
jetty-util
${project.version}
-
- org.eclipse.jetty
- jetty-server
- ${project.version}
-
@@ -98,5 +93,25 @@
org.eclipse.jdt.core.compiler
ecj
+
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ ${project.version}
+ tests
+ test
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ ${project.version}
+ test
+
+
+ org.eclipse.jetty.toolchain
+ jetty-test-helper
+ test
+
diff --git a/apache-jsp/src/main/java/org/eclipse/jetty/apache/jsp/JettyJasperInitializer.java b/apache-jsp/src/main/java/org/eclipse/jetty/apache/jsp/JettyJasperInitializer.java
index 060db780ffc..bbac439e15e 100644
--- a/apache-jsp/src/main/java/org/eclipse/jetty/apache/jsp/JettyJasperInitializer.java
+++ b/apache-jsp/src/main/java/org/eclipse/jetty/apache/jsp/JettyJasperInitializer.java
@@ -29,8 +29,9 @@ import javax.servlet.ServletContext;
import org.apache.jasper.servlet.JasperInitializer;
import org.apache.jasper.servlet.TldPreScanned;
import org.apache.jasper.servlet.TldScanner;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
import org.xml.sax.SAXException;
/**
@@ -38,8 +39,7 @@ import org.xml.sax.SAXException;
*/
public class JettyJasperInitializer extends JasperInitializer
{
- private static final Logger LOG = Log.getLogger(JettyJasperInitializer.class);
-
+ private static final Log LOG = LogFactory.getLog(JasperInitializer.class);
/**
* NullTldScanner
*
@@ -111,6 +111,4 @@ public class JettyJasperInitializer extends JasperInitializer
if (LOG.isDebugEnabled()) LOG.debug("Defaulting to jasper tld scanning");
return super.newTldScanner(context, namespaceAware, validate, blockExternal);
}
-
-
}
diff --git a/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java b/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java
index 6f889dd4d8f..62744692228 100644
--- a/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java
+++ b/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java
@@ -19,6 +19,9 @@
package org.eclipse.jetty.jsp;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
@@ -26,9 +29,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.jasper.servlet.JspServlet;
-import org.eclipse.jetty.server.handler.ContextHandler;
-import org.eclipse.jetty.util.URIUtil;
-import org.eclipse.jetty.util.resource.Resource;
+
/**
* JettyJspServlet
@@ -76,7 +77,7 @@ public class JettyJspServlet extends JspServlet
pathInfo = request.getPathInfo();
}
- String pathInContext = URIUtil.addPaths(servletPath,pathInfo);
+ String pathInContext = addPaths(servletPath,pathInfo);
String jspFile = getInitParameter("jspFile");
@@ -84,7 +85,7 @@ public class JettyJspServlet extends JspServlet
//otherwise the default servlet might handle it
if (jspFile == null)
{
- if (pathInContext.endsWith("/"))
+ if (pathInContext != null && pathInContext.endsWith("/"))
{
//dispatch via forward to the default servlet
getServletContext().getNamedDispatcher("default").forward(req, resp);
@@ -93,13 +94,16 @@ public class JettyJspServlet extends JspServlet
else
{
//check if it resolves to a directory
- Resource resource = ((ContextHandler.Context)getServletContext()).getContextHandler().getResource(pathInContext);
-
- if (resource!=null && resource.isDirectory())
+ String realPath = getServletContext().getRealPath(pathInContext);
+ if (realPath != null)
{
- //dispatch via forward to the default servlet
- getServletContext().getNamedDispatcher("default").forward(req, resp);
- return;
+ Path asPath = Paths.get(realPath);
+ if (Files.exists(asPath) && Files.isDirectory(asPath))
+ {
+ //dispatch via forward to the default servlet
+ getServletContext().getNamedDispatcher("default").forward(req, resp);
+ return;
+ }
}
}
}
@@ -108,5 +112,19 @@ public class JettyJspServlet extends JspServlet
super.service(req, resp);
}
-
+ /**
+ * @param servletPath the servletPath of the request
+ * @param pathInfo the pathInfo of the request
+ * @return servletPath with pathInfo appended
+ */
+ private String addPaths(String servletPath, String pathInfo)
+ {
+ if (servletPath.length()==0)
+ return pathInfo;
+
+ if (pathInfo==null)
+ return servletPath;
+
+ return servletPath+pathInfo;
+ }
}
diff --git a/apache-jsp/src/test/java/org/eclipse/jetty/jsp/TestJettyJspServlet.java b/apache-jsp/src/test/java/org/eclipse/jetty/jsp/TestJettyJspServlet.java
new file mode 100644
index 00000000000..430de11d04d
--- /dev/null
+++ b/apache-jsp/src/test/java/org/eclipse/jetty/jsp/TestJettyJspServlet.java
@@ -0,0 +1,123 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.jsp;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspFactory;
+
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.servlet.ServletTester;
+import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.apache.jasper.runtime.JspFactoryImpl;
+import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.SimpleInstanceManager;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+
+public class TestJettyJspServlet
+{
+ File _dir;
+ ServletTester _tester;
+
+ public static class DfltServlet extends HttpServlet
+ {
+
+ public DfltServlet()
+ {
+ super();
+ }
+
+ /**
+ * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ resp.setContentType("html/text");
+ resp.getOutputStream().println("This.Is.The.Default.");
+ }
+
+ }
+
+ @Before
+ public void setUp () throws Exception
+ {
+ JspFactory.setDefaultFactory(new JspFactoryImpl());
+ _dir = MavenTestingUtils.getTestResourceDir("base");
+ _tester = new ServletTester("/context");
+ _tester.getContext().setClassLoader(new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader()));
+ ServletHolder jspHolder = _tester.getContext().addServlet(JettyJspServlet.class, "/*");
+ jspHolder.setInitParameter("scratchdir", MavenTestingUtils.getTargetTestingDir().getAbsolutePath());
+ _tester.getContext().setResourceBase(_dir.getAbsolutePath());
+ _tester.getContext().setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
+ ServletHolder dfltHolder = new ServletHolder();
+ dfltHolder.setName("default");
+ dfltHolder.setHeldClass( DfltServlet.class);
+ _tester.getContext().addServlet(dfltHolder, "/");
+
+ _tester.start();
+ }
+
+ @After
+ public void tearDown() throws Exception
+ {
+ if (_tester != null)
+ _tester.stop();
+ }
+
+ @Test
+ public void testWithJsp() throws Exception
+ {
+ //test that an ordinary jsp is served by jsp servlet
+ String request = "" +
+ "GET /context/foo.jsp HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+ String response = _tester.getResponses(request);
+ assertTrue(!response.contains("This.Is.The.Default."));
+ }
+
+
+ @Test
+ public void testWithDirectory() throws Exception
+ {
+ //test that a dir is served by the default servlet
+ String request = "" +
+ "GET /context/dir HTTP/1.1\r\n" +
+ "Host: localhost\r\n" +
+ "Connection: close\r\n" +
+ "\r\n";
+ String response = _tester.getResponses(request);
+ assertTrue(response.contains("This.Is.The.Default."));
+ }
+
+}
diff --git a/apache-jsp/src/test/resources/base/dir/empty.txt b/apache-jsp/src/test/resources/base/dir/empty.txt
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/apache-jsp/src/test/resources/base/foo.jsp b/apache-jsp/src/test/resources/base/foo.jsp
new file mode 100644
index 00000000000..fb73b0b0002
--- /dev/null
+++ b/apache-jsp/src/test/resources/base/foo.jsp
@@ -0,0 +1,23 @@
+
+<%@ page import="java.util.Enumeration" %>
+
+JSP Dump
+
+
+Request URI: | <%= request.getRequestURI() %> |
+ServletPath: | <%= request.getServletPath() %> |
+PathInfo: | <%= request.getPathInfo() %> |
+
+<%
+ Enumeration e =request.getParameterNames();
+ while(e.hasMoreElements())
+ {
+ String name = (String)e.nextElement();
+%>
+
+ getParameter("<%= name %>") |
+ <%= request.getParameter(name) %> |
+<% } %>
+
+
+
diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_111.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_111.mod
new file mode 100644
index 00000000000..8923d6a9026
--- /dev/null
+++ b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_111.mod
@@ -0,0 +1,8 @@
+[name]
+alpn-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.9.v20160720/alpn-boot-8.1.9.v20160720.jar|lib/alpn/alpn-boot-8.1.9.v20160720.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.9.v20160720.jar
diff --git a/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_112.mod b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_112.mod
new file mode 100644
index 00000000000..cfdaff16d1a
--- /dev/null
+++ b/jetty-alpn/jetty-alpn-server/src/main/config/modules/alpn-impl/alpn-1.8.0_112.mod
@@ -0,0 +1,8 @@
+[name]
+alpn-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.10.v20161026/alpn-boot-8.1.10.v20161026.jar|lib/alpn/alpn-boot-8.1.10.v20161026.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.10.v20161026.jar
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/PreEncodedHttpField.java b/jetty-http/src/main/java/org/eclipse/jetty/http/PreEncodedHttpField.java
index 6c81a914693..8a49a986660 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/PreEncodedHttpField.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/PreEncodedHttpField.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.http;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceLoader;
@@ -51,30 +52,56 @@ public class PreEncodedHttpField extends HttpField
{
try
{
- encoders.add(iter.next());
+ HttpFieldPreEncoder encoder = iter.next();
+ if (index(encoder.getHttpVersion())>=0)
+ encoders.add(encoder);
}
catch(Error|RuntimeException e)
{
LOG.debug(e);
}
}
- // TODO avoid needing this catch all
- if (encoders.size()==0)
- encoders.add(new Http1FieldPreEncoder());
LOG.debug("HttpField encoders loaded: {}",encoders);
- __encoders = encoders.toArray(new HttpFieldPreEncoder[encoders.size()]);
+ int size=encoders.size();
+
+ __encoders = new HttpFieldPreEncoder[size==0?1:size];
+ for (HttpFieldPreEncoder e:encoders)
+ {
+ int i = index(e.getHttpVersion());
+ if (__encoders[i]==null)
+ __encoders[i] = e;
+ else
+ LOG.warn("multiple PreEncoders for "+e.getHttpVersion());
+ }
+
+ // Always support HTTP1
+ if (__encoders[0]==null)
+ __encoders[0] = new Http1FieldPreEncoder();
}
- private final byte[][] _encodedField=new byte[2][];
+ private static int index(HttpVersion version)
+ {
+ switch (version)
+ {
+ case HTTP_1_0:
+ case HTTP_1_1:
+ return 0;
+
+ case HTTP_2:
+ return 1;
+
+ default:
+ return -1;
+ }
+ }
+
+ private final byte[][] _encodedField=new byte[__encoders.length][];
public PreEncodedHttpField(HttpHeader header,String name,String value)
{
super(header,name, value);
-
- for (HttpFieldPreEncoder e:__encoders)
- {
- _encodedField[e.getHttpVersion()==HttpVersion.HTTP_2?1:0]=e.getEncodedField(header,header.asString(),value);
- }
+ for (int i=0;i<__encoders.length;i++)
+ _encodedField[i]=__encoders[i].getEncodedField(header,header.asString(),value);
}
public PreEncodedHttpField(HttpHeader header,String value)
@@ -89,6 +116,6 @@ public class PreEncodedHttpField extends HttpField
public void putTo(ByteBuffer bufferInFillMode, HttpVersion version)
{
- bufferInFillMode.put(_encodedField[version==HttpVersion.HTTP_2?1:0]);
+ bufferInFillMode.put(_encodedField[index(version)]);
}
}
\ No newline at end of file
diff --git a/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_111.mod b/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_111.mod
new file mode 100644
index 00000000000..8923d6a9026
--- /dev/null
+++ b/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_111.mod
@@ -0,0 +1,8 @@
+[name]
+alpn-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.9.v20160720/alpn-boot-8.1.9.v20160720.jar|lib/alpn/alpn-boot-8.1.9.v20160720.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.9.v20160720.jar
diff --git a/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_112.mod b/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_112.mod
new file mode 100644
index 00000000000..cfdaff16d1a
--- /dev/null
+++ b/jetty-start/src/test/resources/dist-home/modules/alpn-impl/alpn-1.8.0_112.mod
@@ -0,0 +1,8 @@
+[name]
+alpn-boot
+
+[files]
+http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.10.v20161026/alpn-boot-8.1.10.v20161026.jar|lib/alpn/alpn-boot-8.1.10.v20161026.jar
+
+[exec]
+-Xbootclasspath/p:lib/alpn/alpn-boot-8.1.10.v20161026.jar
diff --git a/pom.xml b/pom.xml
index 538e881a911..6f2a1cd3a8e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1162,24 +1162,28 @@
- jdk9
+ 8u111
- 1.9
+
+ java.version
+ 1.8.0_111
+
-
-
-
- maven-compiler-plugin
-
-
- 1.9
- 1.9
- 1.9
- -Xlint:all
-
-
-
-
+
+ 8.1.9.v20160720
+
+
+
+ 8u112
+
+
+ java.version
+ 1.8.0_112
+
+
+
+ 8.1.10.v20161026
+