Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-11-25 23:35:30 -0500
committerJan Bartel2014-11-25 23:36:36 -0500
commit16737804c85fcab8e189fb59105182fa99de1ed3 (patch)
tree5aa3baa4dae163f86f5990f4e2afaeca8f0bbf7e
parentbd0cd80b5883358a536bd0bfd71ceb8ceefd20ce (diff)
downloadorg.eclipse.jetty.project-16737804c85fcab8e189fb59105182fa99de1ed3.tar.gz
org.eclipse.jetty.project-16737804c85fcab8e189fb59105182fa99de1ed3.tar.xz
org.eclipse.jetty.project-16737804c85fcab8e189fb59105182fa99de1ed3.zip
452261 - Multiple servlets map to path *.jsp when using jsp-property-group
-rw-r--r--apache-jsp/pom.xml9
-rw-r--r--apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java101
-rw-r--r--jetty-distribution/pom.xml4
-rw-r--r--jetty-jsp/pom.xml14
-rw-r--r--jetty-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java102
-rw-r--r--jetty-osgi/jetty-osgi-boot-jsp/pom.xml3
-rw-r--r--jetty-webapp/src/main/config/etc/webdefault.xml21
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java20
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java2
9 files changed, 243 insertions, 33 deletions
diff --git a/apache-jsp/pom.xml b/apache-jsp/pom.xml
index 05545919a4..a2cf5506d7 100644
--- a/apache-jsp/pom.xml
+++ b/apache-jsp/pom.xml
@@ -27,7 +27,9 @@
<configuration>
<instructions>
<Bundle-Description>Jetty-specific ServletContainerInitializer for Jasper</Bundle-Description>
- <Export-Package>org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
+ <Export-Package>org.eclipse.jetty.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}",
+ org.eclipse.jetty.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
+ </Export-Package>
<Require-Capability>osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
<Provide-Capability>osgi.serviceloader; osgi.serviceloader=javax.servlet.ServletContainerInitializer</Provide-Capability>
<_nouses>true</_nouses>
@@ -85,6 +87,11 @@
<artifactId>jetty-util</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Schemas -->
<dependency>
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
new file mode 100644
index 0000000000..abe8d217c8
--- /dev/null
+++ b/apache-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java
@@ -0,0 +1,101 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2014 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 java.io.IOException;
+
+import javax.servlet.ServletException;
+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
+ *
+ * Wrapper for the jsp servlet that handles receiving requests mapped from
+ * jsp-property-groups. Mappings could be wildcard urls like "/*", which would
+ * include welcome files, but we need those to be handled by the DefaultServlet.
+ */
+public class JettyJspServlet extends JspServlet
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5387857473125086791L;
+
+ @Override
+ public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+
+
+ HttpServletRequest request = null;
+ if (req instanceof HttpServletRequest)
+ request = (HttpServletRequest)req;
+ else
+ throw new ServletException("Request not HttpServletRequest");
+
+ String servletPath=null;
+ String pathInfo=null;
+ if (request.getAttribute("javax.servlet.include.request_uri")!=null)
+ {
+ servletPath=(String)request.getAttribute("javax.servlet.include.servlet_path");
+ pathInfo=(String)request.getAttribute("javax.servlet.include.path_info");
+ if (servletPath==null)
+ {
+ servletPath=request.getServletPath();
+ pathInfo=request.getPathInfo();
+ }
+ }
+ else
+ {
+ servletPath = request.getServletPath();
+ pathInfo = request.getPathInfo();
+ }
+
+ String pathInContext = URIUtil.addPaths(servletPath,pathInfo);
+
+ if (pathInContext.endsWith("/"))
+ {
+ //dispatch via forward to the default servlet
+ getServletContext().getNamedDispatcher("default").forward(req, resp);
+ return;
+ }
+ else
+ {
+ //check if it resolves to a directory
+ Resource resource = ((ContextHandler.Context)getServletContext()).getContextHandler().getResource(pathInContext);
+ if (resource!=null && resource.isDirectory())
+ {
+ //dispatch via forward to the default servlet
+ getServletContext().getNamedDispatcher("default").forward(req, resp);
+ return;
+ }
+ }
+
+ //fall through to the normal jsp servlet handling
+ super.service(req, resp);
+ }
+
+
+}
diff --git a/jetty-distribution/pom.xml b/jetty-distribution/pom.xml
index 1b3fa08c81..dbeb707516 100644
--- a/jetty-distribution/pom.xml
+++ b/jetty-distribution/pom.xml
@@ -464,8 +464,8 @@
<goal>copy-dependencies</goal>
</goals>
<configuration>
- <includeGroupIds>org.eclipse.jetty.orbit,org.glassfish.web, org.glassfish, javax.el, javax.servlet.jsp, org.eclipse.jetty.toolchain</includeGroupIds>
- <includeArtifactIds>org.eclipse.jdt.core, javax.servlet.jsp-api, javax.servlet.jsp, jetty-jsp-jdt, javax.el-api, javax.el</includeArtifactIds>
+ <includeGroupIds>org.eclipse.jetty.orbit,org.glassfish.web, org.glassfish, javax.el, javax.servlet.jsp, org.eclipse.jetty.toolchain, org.eclipse.jetty</includeGroupIds>
+ <includeArtifactIds>org.eclipse.jdt.core, javax.servlet.jsp-api, javax.servlet.jsp, jetty-jsp-jdt, javax.el-api, javax.el, jetty-jsp</includeArtifactIds>
<includeTypes>jar</includeTypes>
<outputDirectory>${assembly-directory}/lib/jsp</outputDirectory>
</configuration>
diff --git a/jetty-jsp/pom.xml b/jetty-jsp/pom.xml
index 455defe9b2..7109a2c37c 100644
--- a/jetty-jsp/pom.xml
+++ b/jetty-jsp/pom.xml
@@ -32,6 +32,20 @@
</build>
<dependencies>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Schemas -->
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
diff --git a/jetty-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java b/jetty-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java
new file mode 100644
index 0000000000..db7fe085b2
--- /dev/null
+++ b/jetty-jsp/src/main/java/org/eclipse/jetty/jsp/JettyJspServlet.java
@@ -0,0 +1,102 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2014 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 java.io.IOException;
+
+import javax.servlet.ServletException;
+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
+ *
+ * Wrapper for the jsp servlet that handles receiving requests mapped from
+ * jsp-property-groups. Mappings could be wildcard urls like "/*", which would
+ * include welcome files, but we need those to be handled by the DefaultServlet.
+ */
+public class JettyJspServlet extends JspServlet
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5387857473125086791L;
+
+ @Override
+ public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+
+
+ HttpServletRequest request = null;
+ if (req instanceof HttpServletRequest)
+ request = (HttpServletRequest)req;
+ else
+ throw new ServletException("Request not HttpServletRequest");
+
+ String servletPath=null;
+ String pathInfo=null;
+ if (request.getAttribute("javax.servlet.include.request_uri")!=null)
+ {
+ servletPath=(String)request.getAttribute("javax.servlet.include.servlet_path");
+ pathInfo=(String)request.getAttribute("javax.servlet.include.path_info");
+ if (servletPath==null)
+ {
+ servletPath=request.getServletPath();
+ pathInfo=request.getPathInfo();
+ }
+ }
+ else
+ {
+ servletPath = request.getServletPath();
+ pathInfo = request.getPathInfo();
+ }
+
+ String pathInContext = URIUtil.addPaths(servletPath,pathInfo);
+
+ if (pathInContext.endsWith("/"))
+ {
+ //dispatch via forward to the default servlet
+ getServletContext().getNamedDispatcher("default").forward(req, resp);
+ return;
+ }
+ else
+ {
+ //check if it resolves to a directory
+ Resource resource = ((ContextHandler.Context)getServletContext()).getContextHandler().getResource(pathInContext);
+ if (resource!=null && resource.isDirectory())
+ {
+ //dispatch via forward to the default servlet
+ getServletContext().getNamedDispatcher("default").forward(req, resp);
+ return;
+ }
+ }
+
+ //fall through to the normal jsp servlet handling
+ super.service(req, resp);
+ }
+
+
+}
diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
index 2640916902..2976531aca 100644
--- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
+++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
@@ -163,6 +163,7 @@
org.apache.taglibs.standard.tei;version="1.2";resolution:=optional,
org.apache.taglibs.standard.tlv;version="1.2";resolution:=optional,
org.apache.tomcat;version="[8.0.9,9)";resolution:=optional,
+ org.eclipse.jetty.jsp;version="[9.2,10)";resolution:=optional,
org.osgi.*,
org.xml.*;resolution:=optional,
org.xml.sax.*;resolution:=optional,
@@ -172,7 +173,7 @@
javax.xml.parser;resolution:=optional
</Import-Package>
<_nouses>true</_nouses>
- <DynamicImport-Package>org.apache.jasper.*;version="8.0.9",org.apache.el.*;version="8.0.9"</DynamicImport-Package>
+ <DynamicImport-Package>org.eclipse.jetty.jsp.*;version="9.2.6",org.apache.jasper.*;version="8.0.9",org.apache.el.*;version="8.0.9"</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
diff --git a/jetty-webapp/src/main/config/etc/webdefault.xml b/jetty-webapp/src/main/config/etc/webdefault.xml
index e2ad2a7ef9..83d06445f6 100644
--- a/jetty-webapp/src/main/config/etc/webdefault.xml
+++ b/jetty-webapp/src/main/config/etc/webdefault.xml
@@ -201,13 +201,13 @@
<!-- ==================================================================== -->
<!-- JSP Servlet -->
- <!-- This is the jasper JSP servlet from the jakarta project -->
+ <!-- This is the jasper JSP servlet. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The JSP page compiler and execution servlet, which is the mechanism -->
- <!-- used by Glassfish to support JSP pages. Traditionally, this servlet -->
- <!-- is mapped to URL patterh "*.jsp". This servlet supports the -->
- <!-- following initialization parameters (default values are in square -->
- <!-- brackets): -->
+ <!-- used by the jsp container to support JSP pages. Traditionally, -->
+ <!-- this servlet is mapped to URL pattern "*.jsp". This servlet -->
+ <!-- supports the following initialization parameters (default values -->
+ <!-- are in square brackets): -->
<!-- -->
<!-- checkInterval If development is false and reloading is true, -->
<!-- background compiles are enabled. checkInterval -->
@@ -215,7 +215,7 @@
<!-- if a JSP page needs to be recompiled. [300] -->
<!-- -->
<!-- compiler Which compiler Ant should use to compile JSP -->
- <!-- pages. See the Ant documenation for more -->
+ <!-- pages. See the Ant documentation for more -->
<!-- information. [javac] -->
<!-- -->
<!-- classdebuginfo Should the class file be compiled with -->
@@ -276,17 +276,10 @@
<!-- xpoweredBy Determines whether X-Powered-By response -->
<!-- header is added by generated servlet [false] -->
<!-- -->
- <!-- If you wish to use Jikes to compile JSP pages: -->
- <!-- Set the init parameter "compiler" to "jikes". Define -->
- <!-- the property "-Dbuild.compiler.emacs=true" when starting Jetty -->
- <!-- to cause Jikes to emit error messages in a format compatible with -->
- <!-- Jasper. -->
- <!-- If you get an error reporting that jikes can't use UTF-8 encoding, -->
- <!-- try setting the init parameter "javaEncoding" to "ISO-8859-1". -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<servlet id="jsp">
<servlet-name>jsp</servlet-name>
- <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+ <servlet-class>org.eclipse.jetty.jsp.JettyJspServlet</servlet-class>
<init-param>
<param-name>logVerbosityLevel</param-name>
<param-value>DEBUG</param-value>
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java
index 9e64443c35..88fac6502e 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java
@@ -18,7 +18,6 @@
package org.eclipse.jetty.webapp;
-import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
@@ -34,21 +33,20 @@ import java.util.Set;
import javax.servlet.DispatcherType;
import javax.servlet.MultipartConfigElement;
+import javax.servlet.ServletException;
import javax.servlet.SessionTrackingMode;
import org.eclipse.jetty.security.ConstraintAware;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.authentication.FormAuthenticator;
+import org.eclipse.jetty.servlet.BaseHolder.Source;
import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.FilterMapping;
-import org.eclipse.jetty.servlet.BaseHolder.Source;
-import org.eclipse.jetty.servlet.JspPropertyGroupServlet;
import org.eclipse.jetty.servlet.ListenerHolder;
import org.eclipse.jetty.servlet.ServletContextHandler.JspConfig;
import org.eclipse.jetty.servlet.ServletContextHandler.JspPropertyGroup;
import org.eclipse.jetty.servlet.ServletContextHandler.TagLib;
-import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletMapping;
import org.eclipse.jetty.util.ArrayUtil;
@@ -1398,10 +1396,10 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
List<String> paths = new ArrayList<String>();
while (iter.hasNext())
{
+
JspPropertyGroup jpg = new JspPropertyGroup();
config.addJspPropertyGroup(jpg);
XmlParser.Node group = iter.next();
-
//url-patterns
Iterator<XmlParser.Node> iter2 = group.iterator("url-pattern");
while (iter2.hasNext())
@@ -1440,19 +1438,11 @@ public class StandardDescriptorProcessor extends IterativeDescriptorProcessor
if (LOG.isDebugEnabled()) LOG.debug(config.toString());
}
+ //add mappings to the jsp servlet from the property-group mappings
if (paths.size() > 0)
{
- ServletHandler handler = context.getServletHandler();
- ServletHolder jsp_pg_servlet = _servletHolderMap.get(JspPropertyGroupServlet.NAME);
- if (jsp_pg_servlet==null)
- {
- jsp_pg_servlet=new ServletHolder(JspPropertyGroupServlet.NAME,new JspPropertyGroupServlet(context,handler));
- _servletHolderMap.put(JspPropertyGroupServlet.NAME,jsp_pg_servlet);
- _servletHolders.add(jsp_pg_servlet);
- }
-
ServletMapping mapping = new ServletMapping();
- mapping.setServletName(JspPropertyGroupServlet.NAME);
+ mapping.setServletName("jsp");
mapping.setPathSpecs(paths.toArray(new String[paths.size()]));
_servletMappings.add(mapping);
}
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
index 3a709a406e..406b8bbe70 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java
@@ -118,6 +118,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"org.eclipse.jetty.util.log.", // webapp should use server log
"org.eclipse.jetty.servlet.ServletContextHandler.Decorator", // for CDI / weld use
"org.eclipse.jetty.servlet.DefaultServlet", // webapp cannot change default servlets
+ "org.eclipse.jetty.jsp.JettyJspServlet", //webapp cannot change jetty jsp servlet
"org.eclipse.jetty.servlets.AsyncGzipFilter" // special case for AsyncGzipFilter
} ;
@@ -132,6 +133,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"-org.eclipse.jetty.jaas.", // don't hide jaas classes
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
"-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet
+ "-org.eclipse.jetty.jsp.", //don't hide jsp servlet
"-org.eclipse.jetty.servlet.listener.", // don't hide useful listeners
"-org.eclipse.jetty.websocket.", // don't hide websocket classes from webapps (allow webapp to use ones from system classloader)
"-org.eclipse.jetty.apache.", // don't hide jetty apache impls

Back to the top