Examples of Servlet


Examples of javax.servlet.Servlet

        return dispatcher;
    }

    public void destroy()
    {
        final Servlet servlet = dispatcher.getServlet();
        final ServletConfig cfg = servlet.getServletConfig();
        final ServletContext context = cfg != null ? cfg.getServletContext() : null;
        servlet.destroy();
        if (context != null) {
          contextManager.ungetServletContext(context);
        }
        registrations.removeServlet(servlet);
    }
View Full Code Here

Examples of javax.servlet.Servlet

               IOException
    {
        if (_class==null)
            throw new UnavailableException("Servlet Not Initialized");
       
        Servlet servlet = getServletInstance();
        synchronized(this)
        {
            if (!isAvailable() || !isSetInitOrder())
                servlet=getServlet();
            if (servlet==null)
                throw new UnavailableException("Could not instantiate "+_class);
        }
       
        // Service the request
        boolean servlet_error=true;
       
        try
        {           
            servlet.service(request,response);
            servlet_error=false;
        }
        catch(UnavailableException e)
        {
            makeUnavailable(e);
View Full Code Here

Examples of javax.servlet.Servlet

      if (_protocolFactory == null)
        throw new IllegalStateException(L.l("unknown protocol factory for '{0}'",
                                            this));

      Servlet servlet
        = _protocolFactory.createServlet(getServletClass(), service);

      servlet.init(this);

      return servlet;
    } catch (RuntimeException e) {
      throw e;
    } catch (ServletException e) {
View Full Code Here

Examples of javax.servlet.Servlet

      if (servlet instanceof Page) {
        // server/102i
        // page already configured
      }
      else if (servlet instanceof Servlet) {
        Servlet servletObj = (Servlet) servlet;

        servletObj.init(this);
      }
    } catch (UnavailableException e) {
      setInitException(e);
      throw e;
    }
View Full Code Here

Examples of javax.servlet.Servlet

   */
  public void doFilter(ServletRequest request,
                       ServletResponse response)
    throws ServletException, IOException
  {
    Servlet servlet = null;

    synchronized (this) {
      servlet = _servlet;
      _servlet = null;
    }
   
    if (servlet == null) {
      try {
        servlet = (Servlet) _config.createServlet(true);
      } catch (ServletException e) {
        throw e;
      } catch (Exception e) {
        throw new ServletException(e);
      }
    }
   
    try {
      servlet.service(request, response);
    } catch (UnavailableException e) {
      _config.setInitException(e);
      // application.killServlet(servlet, config);

      throw e;
    }

    synchronized (this) {
      if (_servlet == null) {
        _servlet = servlet;
        servlet = null;
      }
    }

    if (servlet != null)
      servlet.destroy();
  }
View Full Code Here

Examples of javax.servlet.Servlet

    /**
     * hook to register that we need to scan for security annotations.
     * @param wrapper   The wrapper for the Servlet that was added
     */
    public ServletRegistration.Dynamic dynamicServletAdded(Wrapper wrapper) {
        Servlet s = wrapper.getServlet();
        if (s != null && createdServlets.contains(s)) {
            // Mark the wrapper to indicate annotations need to be scanned
            wrapper.setServletSecurityAnnotationScanRequired(true);
        }
        return new ApplicationServletRegistration(wrapper, this);
View Full Code Here

Examples of javax.servlet.Servlet

        ClassLoader old = Thread.currentThread().getContextClassLoader();
        ClassLoader webappClassLoader =
                ((Context) getParent()).getLoader().getClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(webappClassLoader);
            Servlet s = allocate();
            deallocate(s);
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
        } finally {
            Thread.currentThread().setContextClassLoader(old);
View Full Code Here

Examples of javax.servlet.Servlet

        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) {
                e = ExceptionUtils.unwrapInvocationTargetException(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);
                }
            }

            processServletSecurityAnnotation(servlet.getClass());

            // Special handling for ContainerServlet instances
            if ((servlet instanceof ContainerServlet) &&
                    (isContainerProvidedServlet(servletClass) ||
                            ((Context) getParent()).getPrivileged() )) {
View Full Code Here

Examples of javax.servlet.Servlet

        }

        if (singleThreadModel && (instancePool != null)) {
            try {
                while (!instancePool.isEmpty()) {
                    Servlet s = instancePool.pop();
                    if (Globals.IS_SECURITY_ENABLED) {
                        try {
                            SecurityUtil.doAsPrivilege("destroy", s);
                        } finally {
                            SecurityUtil.remove(s);
                        }
                    } else {
                        s.destroy();
                    }
                    // Annotation processing
                    if (!((Context) getParent()).getIgnoreAnnotations()) {
                       ((StandardContext)getParent()).getInstanceManager().destroyInstance(s);
                    }
View Full Code Here

Examples of javax.servlet.Servlet

    }

    @SuppressWarnings("unchecked")
    private Servlet loadServlet()
    throws ServletException, IOException {
        Servlet servlet = null;

        try {
            if ( log.isDebugEnabled() ) {
                log.debug("Loading servlet " + jspUri);
            }
            servlet = (Servlet) ctxt.load().newInstance();
            AnnotationProcessor annotationProcessor = (AnnotationProcessor) config.getServletContext().getAttribute(AnnotationProcessor.class.getName());
            if (annotationProcessor != null) {
               annotationProcessor.processAnnotations(servlet);
               annotationProcessor.postConstruct(servlet);
            }
            // update dependents
            final List<String> oldDeps = this.dependents;
            if (servlet != null && servlet instanceof JspSourceDependent) {
                this.dependents = (List<String>) ((JspSourceDependent) servlet).getDependants();
                if ( this.dependents == null ) {
                    this.dependents = Collections.EMPTY_LIST;
                }
                this.ctxt.getRuntimeContext().addJspDependencies(this, this.dependents);
            }
            if ( !equals(oldDeps, this.dependents) ) {
                this.persistDependencies();
            }
        } catch (final IllegalAccessException e) {
            throw new JasperException(e);
        } catch (final InstantiationException e) {
            throw new JasperException(e);
        } catch (final Exception e) {
            throw new JasperException(e);
        }

        servlet.init(config);

        return servlet;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.