private static StandardContext addContext(Tomcat tomcat, String contextPath, File dir) { try { StandardContext context = (StandardContext) tomcat.addWebapp(contextPath, dir.getAbsolutePath()); context.setClearReferencesHttpClientKeepAliveThread(false); context.setClearReferencesStopThreads(false); context.setClearReferencesStopTimerThreads(false); context.setClearReferencesStopTimerThreads(false); context.setAntiResourceLocking(false); context.setReloadable(false); context.setUseHttpOnly(true); context.setTldValidation(false); context.setXmlValidation(false); context.setXmlNamespaceAware(false); context.setUseNaming(false); context.setDelegate(true); context.setJarScanner(new NullJarScanner()); context.setAllowCasualMultipartParsing(true); context.setCookies(false); // disable JSP and WebSocket support context.setContainerSciFilter("org.apache.tomcat.websocket.server.WsSci|org.apache.jasper.servlet.JasperInitializer"); return context; } catch (ServletException e) { throw new IllegalStateException("Fail to configure webapp from " + dir, e); } }
/** * Sets the session tracking modes that are to become effective for this * <tt>ServletContext</tt>. */ @Override public void setSessionTrackingModes( Set<SessionTrackingMode> sessionTrackingModes) { if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) { String msg = MessageFormat.format(rb.getString(LogFacade.UNSUPPORTED_TRACKING_MODE_EXCEPTION), new Object[] {SessionTrackingMode.SSL, getName()}); throw new IllegalArgumentException(msg); } if (isContextInitializedCalled) { String msg = MessageFormat.format(rb.getString(LogFacade.SERVLET_CONTEXT_ALREADY_INIT_EXCEPTION), new Object[] {"setSessionTrackingModes", getName()}); throw new IllegalStateException(msg); } this.sessionTrackingModes = Collections.unmodifiableSet(sessionTrackingModes); if (sessionTrackingModes.contains(SessionTrackingMode.COOKIE)) { setCookies(true); } else { setCookies(false); } if (sessionTrackingModes.contains(SessionTrackingMode.URL)) { setEnableURLRewriting(true); } else { setEnableURLRewriting(false); } }
context.setCookies(true); log.debug("Enabling session cookies"); break; case JBossWebMetaData.SESSION_COOKIES_DISABLED: context.setCookies(false); log.debug("Disabling session cookies"); break;
private static StandardContext addContext(Tomcat tomcat, String contextPath, File dir) { try { StandardContext context = (StandardContext) tomcat.addWebapp(contextPath, dir.getAbsolutePath()); context.setClearReferencesHttpClientKeepAliveThread(false); context.setClearReferencesStopThreads(false); context.setClearReferencesStopTimerThreads(false); context.setClearReferencesStopTimerThreads(false); context.setAntiResourceLocking(false); context.setReloadable(false); context.setUseHttpOnly(true); context.setTldValidation(false); context.setXmlValidation(false); context.setXmlNamespaceAware(false); context.setUseNaming(false); context.setDelegate(true); context.setJarScanner(new NullJarScanner()); context.setAllowCasualMultipartParsing(true); context.setCookies(false); // disable JSP and WebSocket support context.setContainerSciFilter("org.apache.tomcat.websocket.server.WsSci|org.apache.jasper.servlet.JasperInitializer"); return context; } catch (ServletException e) { throw new IllegalStateException("Fail to configure webapp from " + dir, e); } }