code:     public synchronized Servlet loadServlet() throws ServletException {
  
          // Nothing to do if we already have an instance or an instance pool
          if (!singleThreadModel && (instance != null))
              return instance;
  
          PrintStream out = System.out;
          if (swallowOutput) {
              SystemLogHandler.startCapture();
          }
  
          Servlet servlet;
          try {
              long t1=System.currentTimeMillis();
              // Complain if no servlet class has been specified
              if (servletClass == null) {
                  unavailable(null);
                  throw new ServletException
                      (sm.getString("standardWrapper.notClass", getName()));
              }
  
              InstanceManager instanceManager = ((StandardContext)getParent()).getInstanceManager();
              try {
                  servlet = (Servlet) instanceManager.newInstance(servletClass);
              } catch (ClassCastException e) {
                  unavailable(null);
                  // Restore the context ClassLoader
                  throw new ServletException
                      (sm.getString("standardWrapper.notServlet", servletClass), e);
              } catch (Throwable e) {
                  ExceptionUtils.handleThrowable(e);
                  unavailable(null);
  
                  // Added extra log statement for Bugzilla 36630:
                  // http://issues.apache.org/bugzilla/show_bug.cgi?id=36630
                  if(log.isDebugEnabled()) {
                      log.debug(sm.getString("standardWrapper.instantiate", servletClass), e);
                  }
  
                  // Restore the context ClassLoader
                  throw new ServletException
                      (sm.getString("standardWrapper.instantiate", servletClass), e);
              }
  
              if (multipartConfigElement == null) {
                  MultipartConfig annotation =
                          servlet.getClass().getAnnotation(MultipartConfig.class);
                  if (annotation != null) {
                      multipartConfigElement =
                              new MultipartConfigElement(annotation);
                  }
              }
  
              ServletSecurity secAnnotation =
                  servlet.getClass().getAnnotation(ServletSecurity.class);
              Context ctxt = (Context) getParent();
              if (secAnnotation != null) {
                  ctxt.addServletSecurity(
                          new ApplicationServletRegistration(this, ctxt),
                          new ServletSecurityElement(secAnnotation));
              }
              
  
              // Special handling for ContainerServlet instances
              if ((servlet instanceof ContainerServlet) &&
                    (isContainerProvidedServlet(servletClass) ||
                      ctxt.getPrivileged() )) {
                  ((ContainerServlet) servlet).setWrapper(this);
              }
  
              classLoadTime=(int) (System.currentTimeMillis() -t1);
  
              initServlet(servlet);
  
              // Register our newly initialized instance
              singleThreadModel = servlet instanceof SingleThreadModel;
              if (singleThreadModel) {
                  if (instancePool == null)
                      instancePool = new Stack<Servlet>();
              }
              fireContainerEvent("load", this);
  
              loadTime=System.currentTimeMillis() -t1;
          } finally {
              if (swallowOutput) {
                  String log = SystemLogHandler.stopCapture();
                  if (log != null && log.length() > 0) {
                      if (getServletContext() != null) {
                          getServletContext().log(log);
                      } else {
                          out.println(log);
                      }
                  }
              }
          }
          return servlet;
  
      }
  
  