From 8d42a32e9abde1723486822f4c91ee0b389e76c8 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 5 May 2010 15:03:37 +0000 Subject: [PATCH] 306353 fixed cross context dispatch to root context git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1723 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../jetty/server/handler/ContextHandler.java | 5 ++--- .../src/main/java/com/acme/Dump.java | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 10d3ac3bb54..edeeb97c6b2 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1,4 +1,5 @@ + + 306353 fixed cross context dispatch to root context. + 311154 Added deprecated StringBuffer API for backwards compatibility + 311554 Protect shutdown thread from Server#doStop diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index 198351c00b5..4fb80cdc679 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -1457,8 +1457,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server. */ public ServletContext getContext(String uripath) { - // TODO this is a very poor implementation! - // TODO move this to Server ContextHandler context=null; Handler[] handlers = getServer().getChildHandlersByClass(ContextHandler.class); for (int i=0;icontext.getContextPath().length()) context=ch; diff --git a/test-jetty-webapp/src/main/java/com/acme/Dump.java b/test-jetty-webapp/src/main/java/com/acme/Dump.java index 399d8cd6a62..2a37c3f66e3 100644 --- a/test-jetty-webapp/src/main/java/com/acme/Dump.java +++ b/test-jetty-webapp/src/main/java/com/acme/Dump.java @@ -24,6 +24,7 @@ import java.util.Enumeration; import java.util.Locale; import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletRequestWrapper; @@ -597,13 +598,28 @@ public class Dump extends HttpServlet pout.write(""+"
" + toString(getServletContext().getAttribute(name)) + "
"+""); } - String res= request.getParameter("resource"); if (res != null && res.length() > 0) { pout.write("\n"); pout.write("
Get Resource: \""+res+"\"
"); + + pout.write("\n"); + pout.write("getServletContext().getContext(...): "); + ServletContext context = getServletContext().getContext(res); + pout.write(""+context+""); + + if (context!=null) + { + String cp=context.getContextPath(); + if (cp==null || "/".equals(cp)) + cp=""; + pout.write("\n"); + pout.write("getServletContext().getContext(...),getRequestDispatcher(...): "); + pout.write(""+getServletContext().getContext(res).getRequestDispatcher(res.substring(cp.length()))+""); + } + pout.write("\n"); pout.write("this.getClass().getResource(...): "); pout.write(""+this.getClass().getResource(res)+"");