public Object getAttribute(String name) { if (name.startsWith("org.apache.tomcat")) { // XXX XXX XXX XXX Security - servlets may get too much access !!! // right now we don't check because we need JspServlet to // be able to access classloader and classpath if (name.equals("org.apache.tomcat.jsp_classpath")) { String cp = getServletLoader().getClassPath(); return cp; } if (name.equals("org.apache.tomcat.protection_domain")) { return getProtectionDomain(); } if (name.equals("org.apache.tomcat.classloader")) { return this.getServletLoader().getClassLoader(); } if (name.equals(FacadeManager.FACADE_ATTRIBUTE)) { if (!allowAttribute(name)) return null; return this.getFacadeManager(); } return null; // org.apache.tomcat namespace is reserved in tomcat } else { Object o = attributes.get(name); return attributes.get(name); } }
/** * Maps a named servlet to a particular path or extension. If the named servlet is unregistered, * it will be added and subsequently mapped. * * <p>Note that the order of resolution to handle a request is: * * <p>exact mapped servlet (eg /catalog) prefix mapped servlets (eg /foo/bar/*) extension mapped * servlets (eg *jsp) default servlet */ public void addServletMapping(String path, String servletName) throws TomcatException { if (mappings.get(path) != null) { log("Removing duplicate " + path + " -> " + mappings.get(path)); mappings.remove(path); Container ct = (Container) containers.get(path); removeContainer(ct); } ServletWrapper sw = (ServletWrapper) servlets.get(servletName); if (sw == null) { // Workaround for frequent "bug" in web.xmls // Declare a default mapping log("Mapping with unregistered servlet " + servletName); sw = addServlet(servletName, servletName); } if ("/".equals(path)) defaultServlet = sw; mappings.put(path, sw); Container map = new Container(); map.setContext(this); map.setHandler(sw); map.setPath(path); contextM.addContainer(map); containers.put(path, map); }
/** * Add a servlet with the given name to the container. The servlet will be loaded by the * container's class loader and instantiated using the given class name. * * <p>Called to add a new servlet from web.xml */ public void addServlet(ServletWrapper wrapper) throws TomcatException { wrapper.setContext(this); String name = wrapper.getServletName(); // System.out.println("Adding servlet " + name + " " + wrapper); // check for duplicates if (servlets.get(name) != null) { log("Removing duplicate servlet " + name + " " + wrapper); removeServletByName(name); // getServletByName(name).destroy(); } servlets.put(name, wrapper); }
public ServletWrapper getServletByName(String servletName) { return (ServletWrapper) servlets.get(servletName); }
public Container getContainer(String path) { return (Container) containers.get(path); }
public String getErrorPage(String errorCode) { return (String) errorPages.get(errorCode); }
public String getInitParameter(String name) { return (String) initializationParameters.get(name); }
public String getEnvEntryValue(String name) { return (String) envEntryValues.get(name); }
public String getEnvEntryType(String name) { return (String) envEntryTypes.get(name); }
public String getTaglibLocation(String uri) { return (String) tagLibs.get(uri); }