public String getServletContextName() { String name = ContextHandler.this.getDisplayName(); if (name==null) name=ContextHandler.this.getContextPath(); return name; }
public String toString() { return this.getClass().getName()+"@"+Integer.toHexString(hashCode())+"{"+getContextPath()+","+getBaseResource()+"}"; }
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++) { if (handlers[i]==null || !handlers[i].isStarted()) 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 (context==null || context_path.length()>context.getContextPath().length()) context=ch; } } if (context!=null) return context._scontext; return null; }
protected Collection<String> getContextPaths(LinkedHashSet<String> results, Handler... handlers) { if (handlers != null) { for (Handler handler : handlers) { if (handler instanceof HandlerCollection) { getContextPaths(results, ((HandlerCollection) handler).getHandlers()); } else if (handler instanceof ContextHandler) { results.add(((ContextHandler) handler).getContextPath()); } } } return results; }
@Override public ServletContext getServletContext(final String contextPath) { final Iterable<Handler> handlers = (server.getHandlers() == null ? Collections .singletonList(server.getHandler()) : Arrays.asList(server.getHandlers())); for (final Handler handler : handlers) { if (handler instanceof ContextHandler) { final ContextHandler contextHandler = (ContextHandler) handler; if (ObjectUtils.equals(contextPath, contextHandler.getContextPath())) { return contextHandler.getServletContext(); } } } return null; }
String uri=URIUtil.addPaths(_contextHandler.getContextPath(), uriInContext); return new Dispatcher(_contextHandler, uri, pathInContext, query);
protected void doStart() throws Exception _logger=Log.getLogger(getDisplayName()==null?getContextPath():getDisplayName()); ClassLoader old_classloader=null; Thread current_thread=null;
String contextPath=handler.getContextPath();
if (context.equals(c.getContextPath())) continue files;
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0) writer.write("http://"+context.getVirtualHosts()[0]+":"+request.getLocalPort()); writer.write(context.getContextPath()); if (context.getContextPath().length()>1 && context.getContextPath().endsWith("/")) writer.write("/"); writer.write("\">"); writer.write(context.getContextPath()); if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0) writer.write(" @ "+context.getVirtualHosts()[0]+":"+request.getLocalPort()); writer.write(context.getContextPath()); if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0) writer.write(" @ "+context.getVirtualHosts()[0]+":"+request.getLocalPort());
attr._contextPath=_contextHandler.getContextPath();
base_request.setContextPath(_contextHandler.getContextPath()); base_request.setAttributes(attr); base_request.setQueryString(query);