Java Code Examples for javax.servlet.Servlet#getServletConfig()
The following examples show how to use
javax.servlet.Servlet#getServletConfig() .
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: ServletVersionInstrumentation.java From apm-agent-java with Apache License 2.0 | 5 votes |
@Advice.OnMethodEnter(suppress = Throwable.class) @SuppressWarnings("Duplicates") // duplication is fine here as it allows to inline code private static void onEnter(@Advice.This Servlet servlet) { if (alreadyLogged) { return; } alreadyLogged = true; ServletConfig servletConfig = servlet.getServletConfig(); int majorVersion = -1; int minorVersion = -1; String serverInfo = null; if (servletConfig != null) { ServletContext servletContext = servletConfig.getServletContext(); if (null != servletContext) { majorVersion = servletContext.getMajorVersion(); minorVersion = servletContext.getMinorVersion(); serverInfo = servletContext.getServerInfo(); } } logger.info("Servlet container info = {}", serverInfo); if (majorVersion < 3) { logger.warn("Unsupported servlet version detected: {}.{}, no Servlet transaction will be created", majorVersion, minorVersion); } }
Example 2
Source File: ServletRegistration.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); }
Example 3
Source File: PageContextImpl.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
private void _initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) throws IOException { // initialize state this.servlet = servlet; this.config = servlet.getServletConfig(); this.context = config.getServletContext(); this.needsSession = needsSession; this.errorPageURL = errorPageURL; this.bufferSize = bufferSize; this.request = request; this.response = response; // Setup session (if required) if (request instanceof HttpServletRequest && needsSession) this.session = ((HttpServletRequest)request).getSession(); if (needsSession && session == null) throw new IllegalStateException ("Page needs a session and none is available"); // initialize the initial out ... depth = -1; if (this.baseOut == null) { this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush); } else { this.baseOut.init(response, bufferSize, autoFlush); } this.out = baseOut; this.isNametableInitialized = false; setAttribute(Constants.FIRST_REQUEST_SEEN, "true", APPLICATION_SCOPE); }
Example 4
Source File: PageContextImpl.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) throws IOException { // initialize state this.servlet = servlet; this.config = servlet.getServletConfig(); this.context = config.getServletContext(); this.errorPageURL = errorPageURL; this.request = request; this.response = response; // initialize application context this.applicationContext = JspApplicationContextImpl.getInstance(context); // Setup session (if required) if (request instanceof HttpServletRequest && needsSession) this.session = ((HttpServletRequest) request).getSession(); if (needsSession && session == null) throw new IllegalStateException( "Page needs a session and none is available"); // initialize the initial out ... depth = -1; if (bufferSize == JspWriter.DEFAULT_BUFFER) { bufferSize = Constants.DEFAULT_BUFFER_SIZE; } if (this.baseOut == null) { this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush); } else { this.baseOut.init(response, bufferSize, autoFlush); } this.out = baseOut; // register names/values as per spec setAttribute(OUT, this.out); setAttribute(REQUEST, request); setAttribute(RESPONSE, response); if (session != null) setAttribute(SESSION, session); setAttribute(PAGE, servlet); setAttribute(CONFIG, config); setAttribute(PAGECONTEXT, this); setAttribute(APPLICATION, context); isIncluded = request.getAttribute( RequestDispatcher.INCLUDE_SERVLET_PATH) != null; }
Example 5
Source File: PageContextImpl.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
private void _initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) { // initialize state this.servlet = servlet; this.config = servlet.getServletConfig(); this.context = config.getServletContext(); this.errorPageURL = errorPageURL; this.request = request; this.response = response; // initialize application context this.applicationContext = JspApplicationContextImpl.getInstance(context); // Setup session (if required) if (request instanceof HttpServletRequest && needsSession) this.session = ((HttpServletRequest) request).getSession(); if (needsSession && session == null) throw new IllegalStateException( "Page needs a session and none is available"); // initialize the initial out ... depth = -1; if (bufferSize == JspWriter.DEFAULT_BUFFER) { bufferSize = Constants.DEFAULT_BUFFER_SIZE; } if (this.baseOut == null) { this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush); } else { this.baseOut.init(response, bufferSize, autoFlush); } this.out = baseOut; // register names/values as per spec setAttribute(OUT, this.out); setAttribute(REQUEST, request); setAttribute(RESPONSE, response); if (session != null) setAttribute(SESSION, session); setAttribute(PAGE, servlet); setAttribute(CONFIG, config); setAttribute(PAGECONTEXT, this); setAttribute(APPLICATION, context); isIncluded = request.getAttribute( RequestDispatcher.INCLUDE_SERVLET_PATH) != null; }
Example 6
Source File: PageContextImpl.java From tomcatsrc with Apache License 2.0 | 4 votes |
private void _initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) { // initialize state this.servlet = servlet; this.config = servlet.getServletConfig(); this.context = config.getServletContext(); this.errorPageURL = errorPageURL; this.request = request; this.response = response; // initialize application context this.applicationContext = JspApplicationContextImpl.getInstance(context); // Setup session (if required) if (request instanceof HttpServletRequest && needsSession) this.session = ((HttpServletRequest) request).getSession(); if (needsSession && session == null) throw new IllegalStateException( "Page needs a session and none is available"); // initialize the initial out ... depth = -1; if (bufferSize == JspWriter.DEFAULT_BUFFER) { bufferSize = Constants.DEFAULT_BUFFER_SIZE; } if (this.baseOut == null) { this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush); } else { this.baseOut.init(response, bufferSize, autoFlush); } this.out = baseOut; // register names/values as per spec setAttribute(OUT, this.out); setAttribute(REQUEST, request); setAttribute(RESPONSE, response); if (session != null) setAttribute(SESSION, session); setAttribute(PAGE, servlet); setAttribute(CONFIG, config); setAttribute(PAGECONTEXT, this); setAttribute(APPLICATION, context); isIncluded = request.getAttribute( RequestDispatcher.INCLUDE_SERVLET_PATH) != null; }
Example 7
Source File: ServletConfiguration.java From commons-configuration with Apache License 2.0 | 2 votes |
/** * Create a ServletConfiguration using the initialization parameter of * the specified servlet. * * @param servlet the servlet */ public ServletConfiguration(final Servlet servlet) { this(servlet.getServletConfig()); }