Java Code Examples for javax.servlet.Servlet#init()
The following examples show how to use
javax.servlet.Servlet#init() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Tomcat.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public synchronized Servlet loadServlet() throws ServletException { if (singleThreadModel) { Servlet instance; try { instance = existing.getClass().getConstructor().newInstance(); } catch (ReflectiveOperationException e) { throw new ServletException(e); } instance.init(facade); return instance; } else { if (!instanceInitialized) { existing.init(facade); instanceInitialized = true; } return existing; } }
Example 2
Source File: ServletRegistration.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ServletRegistration(final String alias, final Servlet servlet, Dictionary<String, String> parameters, final HttpContext httpContext, final ServletContextManager contextManager, final Registrations registrations) throws ServletException { if (parameters == null) { parameters = new Hashtable<String, String>(); } if (parameters.get(HttpUtil.SERVLET_NAME_KEY) == null) { parameters.put(HttpUtil.SERVLET_NAME_KEY, servlet.getClass().getName()); } this.contextManager = contextManager; this.registrations = registrations; // Fail fast if servlet already registered! registrations.addServlet(servlet); final ServletContext context = contextManager.getServletContext(httpContext, null); final ServletConfig config = new ServletConfigImpl(parameters, context); servlet.init(config); dispatcher = new RequestDispatcherImpl(alias, servlet, httpContext, lastModificationDate); }
Example 3
Source File: JaxWsWebServicePublisherBeanPostProcessor.java From cxf with Apache License 2.0 | 5 votes |
public void setServletConfig(ServletConfig servletConfig) { try { shadowCxfServlet = (Servlet)servletClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } try { shadowCxfServlet.init(servletConfig); } catch (ServletException ex) { throw new RuntimeException(ex.getMessage(), ex); } }
Example 4
Source File: ServletFilter.java From lemon with Apache License 2.0 | 5 votes |
public void init(FilterConfig filterConfig) throws ServletException { for (Map.Entry<UrlPatternMatcher, Servlet> entry : servletMap .entrySet()) { Servlet servlet = entry.getValue(); servlet.init(new ProxyServletConfig(filterConfig .getServletContext())); } }
Example 5
Source File: JspServletWrapper.java From packagedrone with Eclipse Public License 1.0 | 4 votes |
public Servlet getServlet() throws ServletException, IOException, ClassNotFoundException { if (reload) { synchronized (this) { // Synchronizing on jsw enables simultaneous loading // of different pages, but not the same page. if (reload) { // This is to maintain the original protocol. destroy(); try { servletClass = ctxt.load(); theServlet = (Servlet) servletClass.newInstance(); } catch( IllegalAccessException ex1 ) { throw new JasperException( ex1 ); } catch( InstantiationException ex ) { throw new JasperException( ex ); } theServlet.init(config); if (!firstTime) { ctxt.getRuntimeContext().incrementJspReloadCount(); // Fire the jspReloadedEvent probe event if (jspProbeEmitter != null) { jspProbeEmitter.jspReloadedEvent(jspUri); } } reload = false; // Fire the jspLoadedEvent probe event if (jspProbeEmitter != null) { jspProbeEmitter.jspLoadedEvent(jspUri); } } } } return theServlet; }