Java Code Examples for javax.servlet.ServletContext#getEffectiveMajorVersion()
The following examples show how to use
javax.servlet.ServletContext#getEffectiveMajorVersion() .
These examples are extracted from open source projects.
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 Project: Tomcat8-Source-Read File: TesterTldListener.java License: MIT License | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); servletContext = sc; // Try and use one of the Servlet 3.0 methods that should be blocked try { sc.getEffectiveMajorVersion(); log.append("FAIL-01"); } catch (UnsupportedOperationException uoe) { log.append("PASS-01"); } catch (Exception e) { log.append("FAIL-02"); } }
Example 2
Source Project: Tomcat7.0.67 File: TesterTldListener.java License: Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); // Try and use one of the Servlet 3.0 methods that should be blocked try { servletContext = sce.getServletContext(); sc.getEffectiveMajorVersion(); log.append("FAIL-01"); } catch (UnsupportedOperationException uoe) { log.append("PASS-01"); } catch (Exception e) { log.append("FAIL-02"); } }
Example 3
Source Project: tomcatsrc File: TesterTldListener.java License: Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); // Try and use one of the Servlet 3.0 methods that should be blocked try { servletContext = sce.getServletContext(); sc.getEffectiveMajorVersion(); log.append("FAIL-01"); } catch (UnsupportedOperationException uoe) { log.append("PASS-01"); } catch (Exception e) { log.append("FAIL-02"); } }
Example 4
Source Project: hasor File: InvokerWebApiBinderCreator.java License: Apache License 2.0 | 5 votes |
public static WebApiBinder newBinder(ApiBinder apiBinder) throws IOException { Environment environment = apiBinder.getEnvironment(); Object context = environment.getContext(); if (!(context instanceof ServletContext)) { return null; } ServletContext servletContext = (ServletContext) context; // // .MimeType MimeTypeSupplier mimeTypeContext = new MimeTypeSupplier(servletContext); mimeTypeContext.loadResource("/META-INF/mime.types.xml"); mimeTypeContext.loadResource("mime.types.xml"); apiBinder.bindType(MimeType.class, mimeTypeContext); // //.ServletVersion ServletVersion curVersion = ServletVersion.V2_3; try { environment.getClassLoader().loadClass("javax.servlet.ServletRequestListener"); curVersion = ServletVersion.V2_4; servletContext.getContextPath(); curVersion = ServletVersion.V2_5; servletContext.getEffectiveMajorVersion(); curVersion = ServletVersion.V3_0; servletContext.getVirtualServerName(); curVersion = ServletVersion.V3_1; } catch (Throwable e) { /* 忽略 */ } // // .Binder apiBinder.bindType(ServletContext.class).toInstance(servletContext); apiBinder.bindType(ServletVersion.class).toInstance(curVersion); // return new InvokerWebApiBinder(curVersion, mimeTypeContext, apiBinder); }
Example 5
Source Project: logging-log4j2 File: Log4jServletContainerInitializer.java License: Apache License 2.0 | 5 votes |
@Override public void onStartup(final Set<Class<?>> classes, final ServletContext servletContext) throws ServletException { if (servletContext.getMajorVersion() > 2 && servletContext.getEffectiveMajorVersion() > 2 && !"true".equalsIgnoreCase(servletContext.getInitParameter( Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED ))) { final Logger LOGGER = StatusLogger.getLogger(); LOGGER.debug("Log4jServletContainerInitializer starting up Log4j in Servlet 3.0+ environment."); final FilterRegistration.Dynamic filter = servletContext.addFilter("log4jServletFilter", Log4jServletFilter.class); if (filter == null) { LOGGER.warn("WARNING: In a Servlet 3.0+ application, you should not define a " + "log4jServletFilter in web.xml. Log4j 2 normally does this for you automatically. Log4j 2 " + "web auto-initialization has been canceled."); return; } final Log4jWebLifeCycle initializer = WebLoggerContextUtils.getWebLifeCycle(servletContext); initializer.start(); initializer.setLoggerContext(); // the application is just now starting to start up servletContext.addListener(new Log4jServletContextListener()); filter.setAsyncSupported(true); // supporting async when the user isn't using async has no downsides filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); } }