Author: slaws
Date: Mon Nov 19 02:04:03 2007
New Revision: 596243
URL: http://svn.apache.org/viewvc?rev=596243&view=rev
Log:
The servlet container context path can now be set to add it to the start of any
servlet path that is registered
I have reverted to setting the actual context to "/" and adding the context to
the start of the servlet as the complete path needs to be in the binding URI
which is set from getURIMapping. We could set the context on the Jetty server
and deal with the path separately but this requires changes elsewhere to make
the bindings work and to maintain compatibility with host-tomcat.
Modified:
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
Modified:
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java?rev=596243&r1=596242&r2=596243&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
(original)
+++
incubator/tuscany/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
Mon Nov 19 02:04:03 2007
@@ -185,7 +185,8 @@
}
ContextHandler contextHandler = new ContextHandler();
- contextHandler.setContextPath(contextPath);
+ //contextHandler.setContextPath(contextPath);
+ contextHandler.setContextPath("/");
server.setHandler(contextHandler);
SessionHandler sessionHandler = new SessionHandler();
@@ -220,10 +221,11 @@
}
if (servletPath.endsWith("/")) {
servletPath = servletPath.substring(0, servletPath.length()-1);
- }
+ }
if (!servletPath.startsWith("/")) {
servletPath = '/' + servletPath;
- }
+ }
+
DefaultResourceServlet resourceServlet =
(DefaultResourceServlet)servlet;
DefaultServlet defaultServlet = new
JettyDefaultServlet(servletPath, resourceServlet.getDocumentRoot());
holder = new ServletHolder(defaultServlet);
@@ -232,12 +234,19 @@
holder = new ServletHolder(servlet);
}
servletHandler.addServlet(holder);
+
ServletMapping mapping = new ServletMapping();
mapping.setServletName(holder.getName());
String path = uri.getPath();
+
if (!path.startsWith("/")) {
path = '/' + path;
}
+
+ if (!path.startsWith(contextPath)) {
+ path = contextPath + path;
+ }
+
mapping.setPathSpec(path);
servletHandler.addServletMapping(mapping);
@@ -280,9 +289,17 @@
// Construct the URL
String path = uri.getPath();
+
+
+ if (!path.startsWith("/")) {
+ path = '/' + path;
+ }
+
if (!path.startsWith(contextPath)) {
path = contextPath + path;
}
+
+
URL url;
try {
url = new URL(scheme, host, portNumber, path);
@@ -293,6 +310,11 @@
}
public Servlet getServletMapping(String suri) throws
ServletMappingException {
+
+ if (suri == null){
+ return null;
+ }
+
URI uri = URI.create(suri);
// Get the URI port
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]