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
This commit is contained in:
parent
6337796369
commit
8d42a32e9a
|
@ -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
|
||||
|
||||
|
|
|
@ -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;i<handlers.length;i++)
|
||||
|
@ -1467,7 +1465,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
continue;
|
||||
ContextHandler ch = (ContextHandler)handlers[i];
|
||||
String context_path=ch.getContextPath();
|
||||
if (uripath.equals(context_path) || (uripath.startsWith(context_path)&&uripath.charAt(context_path.length())=='/'))
|
||||
|
||||
if (uripath.equals(context_path) || (uripath.startsWith(context_path)&&uripath.charAt(context_path.length())=='/') || "/".equals(context_path))
|
||||
{
|
||||
if (context==null || context_path.length()>context.getContextPath().length())
|
||||
context=ch;
|
||||
|
|
|
@ -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("<td>"+"<pre>" + toString(getServletContext().getAttribute(name)) + "</pre>"+"</td>");
|
||||
}
|
||||
|
||||
|
||||
String res= request.getParameter("resource");
|
||||
if (res != null && res.length() > 0)
|
||||
{
|
||||
pout.write("</tr><tr>\n");
|
||||
pout.write("<th align=\"left\" colspan=\"2\"><big><br/>Get Resource: \""+res+"\"</big></th>");
|
||||
|
||||
pout.write("</tr><tr>\n");
|
||||
pout.write("<th align=\"right\">getServletContext().getContext(...): </th>");
|
||||
|
||||
ServletContext context = getServletContext().getContext(res);
|
||||
pout.write("<td>"+context+"</td>");
|
||||
|
||||
if (context!=null)
|
||||
{
|
||||
String cp=context.getContextPath();
|
||||
if (cp==null || "/".equals(cp))
|
||||
cp="";
|
||||
pout.write("</tr><tr>\n");
|
||||
pout.write("<th align=\"right\">getServletContext().getContext(...),getRequestDispatcher(...): </th>");
|
||||
pout.write("<td>"+getServletContext().getContext(res).getRequestDispatcher(res.substring(cp.length()))+"</td>");
|
||||
}
|
||||
|
||||
pout.write("</tr><tr>\n");
|
||||
pout.write("<th align=\"right\">this.getClass().getResource(...): </th>");
|
||||
pout.write("<td>"+this.getClass().getResource(res)+"</td>");
|
||||
|
|
Loading…
Reference in New Issue