示例#1
0
 /**
  * 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);
 }
示例#2
0
  public ServletWrapper addServlet(String name, String classN) throws TomcatException {
    ServletWrapper sw = new ServletWrapper();
    sw.setContext(this);

    sw.setServletName(name);
    if (classN.startsWith("/")) {
      sw.setPath(classN);
    } else {
      sw.setServletClass(classN);
    }
    addServlet(sw);
    return sw;
  }