@SuppressWarnings("all") // CHECKSTYLE:OFF private static Object changeContextWritable(ServletContext servletContext, Object lock) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, NamingException { // cette méthode ne peut pas être utilisée avec un simple JdbcDriver assert servletContext != null; final String serverInfo = servletContext.getServerInfo(); if ((serverInfo.contains("Tomcat") || serverInfo.contains("vFabric") || serverInfo.contains("SpringSource tc Runtime")) && System.getProperty("jonas.name") == null) { // on n'exécute cela que si c'est tomcat // et si ce n'est pas tomcat dans jonas final Field field = Class.forName("org.apache.naming.ContextAccessController") .getDeclaredField("readOnlyContexts"); setFieldAccessible(field); @SuppressWarnings("unchecked") final Hashtable<String, Object> readOnlyContexts = (Hashtable<String, Object>) field.get(null); // la clé dans cette Hashtable est normalement // "/Catalina/" + hostName + Parameters.getContextPath(servletContext) ; // hostName vaut en général "localhost" (ou autre selon le Host dans server.xml) // et contextPath vaut "/myapp" par exemple ; // la valeur est un securityToken if (lock == null) { // on utilise clear et non remove au cas où le host ne soit pas localhost dans server.xml // (cf issue 105) final Hashtable<String, Object> clone = new Hashtable<String, Object>(readOnlyContexts); readOnlyContexts.clear(); return clone; } // on remet le contexte not writable comme avant @SuppressWarnings("unchecked") final Hashtable<String, Object> myLock = (Hashtable<String, Object>) lock; readOnlyContexts.putAll(myLock); return null; } else if (serverInfo.contains("jetty")) { // on n'exécute cela que si c'est jetty final Context jdbcContext = (Context) new InitialContext().lookup("java:comp"); final Field field = getAccessibleField(jdbcContext, "_env"); @SuppressWarnings("unchecked") final Hashtable<Object, Object> env = (Hashtable<Object, Object>) field.get(jdbcContext); if (lock == null) { // on rend le contexte writable Object result = env.remove("org.mortbay.jndi.lock"); if (result == null) { result = env.remove("org.eclipse.jndi.lock"); } return result; } // on remet le contexte not writable comme avant env.put("org.mortbay.jndi.lock", lock); env.put("org.eclipse.jndi.lock", lock); return null; } return null; }
/** @param context */ private void initialize(ServletContext context) { AppServer appServer = AppServerDetector.setAppServerForApplication(context); IWMainApplication _iwma = new IWMainApplication(context, appServer); _iwma.setApplicationServer(appServer); this.iwma = _iwma; this.context = context; this.startLogManager(); // IWMainApplication iwma = IWMainApplication.getIWMainApplication(getServletContext()); // sendStartMessage("Initializing IWMainApplicationStarter"); String serverInfo = context.getServerInfo(); String appServerName = appServer.getName(); String appServerVersion = appServer.getVersion(); if (appServer.isOfficiallySupported()) { if (appServerVersion != null) { log.fine( "Detected supported application server '" + appServerName + "' (version " + appServerVersion + ")"); } else { log.fine("Detected supported application server '" + appServerName + "' (unknown version)"); } } else { log.warning( "This application server (" + serverInfo + ") is not officially supported by idegaWeb"); } startup(); }
protected final void logServerInfo(@Nonnull final ServletContext aSC) { // Print Java and Server (e.g. Tomcat) info s_aLogger.info( "Java " + SystemProperties.getJavaVersion() + " running '" + aSC.getServletContextName() + "' on " + aSC.getServerInfo() + " with " + (Runtime.getRuntime().maxMemory() / CGlobal.BYTES_PER_MEGABYTE) + "MB max RAM and Servlet API " + aSC.getMajorVersion() + "." + aSC.getMinorVersion()); // Tell them to use the server VM if possible: final EJVMVendor eJVMVendor = EJVMVendor.getCurrentVendor(); if (eJVMVendor.isSun() && eJVMVendor != EJVMVendor.SUN_SERVER) s_aLogger.warn( "Consider using the Sun Server Runtime by specifiying '-server' on the commandline!"); if (SystemProperties.getJavaVersion().startsWith("1.6.0_14")) s_aLogger.warn( "This Java version is bad for development - breakpoints don't work in the debugger!"); if (getClass().desiredAssertionStatus()) s_aLogger.warn("Java assertions are enabled - this should be disabled in production!"); }
public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException { LOGGER.info("DO GET"); PrintWriter writer = httpServletResponse.getWriter(); String nombreServlet = getServletName(); writer.println("Nombre Servlet:" + nombreServlet); ServletContext servletContext = getServletContext(); writer.println("Nombre Server:" + servletContext.getServerInfo()); writer.println("Contexto Servlet:" + servletContext.getContextPath()); }
@Override public SendTextToServerResult execute( SendTextToServerAction sendTextToServerAction, ExecutionContext executionContext) throws ActionException { String input = sendTextToServerAction.getTextToServer(); if (input == null || input.length() < 4) { input = "guest"; } String serverInfo = servletContext.getServerInfo(); return new SendTextToServerResult("Hello, " + input + "! from " + serverInfo); }
public static void showServletInfo(HttpServlet servlet, PrintStream out) { out.println("Servlet Info"); out.println(" getServletName(): " + servlet.getServletName()); out.println(" getRootPath(): " + getRootPath()); out.println(" Init Parameters:"); Enumeration params = servlet.getInitParameterNames(); while (params.hasMoreElements()) { String name = (String) params.nextElement(); out.println(" " + name + ": " + servlet.getInitParameter(name)); } out.println(); ServletContext context = servlet.getServletContext(); out.println("Context Info"); try { out.println(" context.getResource('/'): " + context.getResource("/")); } catch (java.net.MalformedURLException e) { } // cant happen out.println(" context.getServerInfo(): " + context.getServerInfo()); out.println(" name: " + getServerInfoName(context.getServerInfo())); out.println(" version: " + getServerInfoVersion(context.getServerInfo())); out.println(" context.getInitParameterNames():"); params = context.getInitParameterNames(); while (params.hasMoreElements()) { String name = (String) params.nextElement(); out.println(" " + name + ": " + context.getInitParameter(name)); } out.println(" context.getAttributeNames():"); params = context.getAttributeNames(); while (params.hasMoreElements()) { String name = (String) params.nextElement(); out.println(" context.getAttribute(\"" + name + "\"): " + context.getAttribute(name)); } out.println(); }
void initServletContext(ServletContext context) { assert context != null; this.servletContext = context; final String serverInfo = servletContext.getServerInfo(); jboss = serverInfo.contains("JBoss") || serverInfo.contains("WildFly"); glassfish = serverInfo.contains("GlassFish") || serverInfo.contains("Sun Java System Application Server"); weblogic = serverInfo.contains("WebLogic"); jonas = System.getProperty("jonas.name") != null; connectionInformationsEnabled = Parameters.isSystemActionsEnabled() && !Parameters.isNoDatabase(); }
@Override public String toString() { return new ToStringGenerator(this) .append("ID", m_sID) .append("creationTime", m_nCreationTime) .append("maxInactiveInterval", m_nMaxInactiveInterval) .append("lastAccessedTime", m_nLastAccessedTime) .appendIfNotNull( "servletContext", m_aServletContext == null ? null : m_aServletContext.getServerInfo()) .append("attributes", m_aAttributes) .append("isInvalidated", m_bInvalidated) .append("isNew", m_bIsNew) .toString(); }
private void init_CheckWebLogicWorkaround(Container container) { // test whether param-access workaround needs to be enabled if (servletContext != null && servletContext.getServerInfo() != null && servletContext.getServerInfo().indexOf("WebLogic") >= 0) { LOG.info("WebLogic server detected. Enabling Struts parameter access work-around."); paramsWorkaroundEnabled = true; } else { paramsWorkaroundEnabled = "true" .equals( container.getInstance( String.class, StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)); } }
/** Initialisation. */ @Before public void setUp() { Utils.initialize(); try { final Field field = MonitoringFilter.class.getDeclaredField("instanceCreated"); field.setAccessible(true); field.set(null, false); } catch (final IllegalAccessException e) { throw new IllegalStateException(e); } catch (final NoSuchFieldException e) { throw new IllegalStateException(e); } final ServletContext parametersContext = createNiceMock(ServletContext.class); expect(parametersContext.getMajorVersion()).andReturn(2).anyTimes(); expect(parametersContext.getMinorVersion()).andReturn(5).anyTimes(); expect(parametersContext.getContextPath()).andReturn(CONTEXT_PATH).anyTimes(); expect(parametersContext.getServletContextName()).andReturn("test webapp").anyTimes(); expect(parametersContext.getServerInfo()).andReturn("mock").anyTimes(); replay(parametersContext); Parameters.initialize(parametersContext); verify(parametersContext); final ServletConfig config = createNiceMock(ServletConfig.class); final ServletContext context = createNiceMock(ServletContext.class); expect(config.getServletContext()).andReturn(context).anyTimes(); // anyTimes sur getInitParameter car TestJdbcDriver a pu fixer la propriété système à false expect( context.getInitParameter( Parameters.PARAMETER_SYSTEM_PREFIX + Parameter.DISABLED.getCode())) .andReturn(null) .anyTimes(); expect(config.getInitParameter(Parameter.DISABLED.getCode())).andReturn(null).anyTimes(); expect(context.getMajorVersion()).andReturn(2).anyTimes(); expect(context.getMinorVersion()).andReturn(5).anyTimes(); expect(context.getContextPath()).andReturn(CONTEXT_PATH).anyTimes(); expect(context.getAttribute(ReportServlet.FILTER_CONTEXT_KEY)) .andReturn(new FilterContext()) .anyTimes(); reportServlet = new ReportServlet(); replay(config); replay(context); reportServlet.init(config); verify(config); verify(context); }
@Override public String getProperty(String key) { String prefix = extractPrefix(key); if (!knownParams.contains(prefix == null ? key : prefix)) return null; if (prefix == null) { if (CONTEXT_ROOT.equals(key)) return servletContext.getRealPath(""); if (CONTEXT_PATH.equals(key)) return servletContext.getContextPath(); if (SERVER_INFO.equals(key)) return servletContext.getServerInfo(); if (SERVLET_CONTEXT_NAME.equals(key)) return servletContext.getServletContextName(); } else if (CONTEXT_PREFIX.equals(prefix)) { key = removePrefix(key); String selector = extractPrefix(key); key = removePrefix(key); if (ATTRIBUTE.equals(selector)) return String.valueOf(servletContext.getAttribute(key)); if (INIT_PARAM.equals(selector)) return servletContext.getInitParameter(key); if (MIME_TYPE.equals(selector)) return servletContext.getMimeType(key); } return null; }
/** * Prepare text. * * @param request The HTTP request * @return Builder of text */ private StringBuilder text(final HttpServletRequest request) { final StringBuilder text = new StringBuilder(); text.append(Logger.format("date: %s\n", new Date())); this.append(text, request, "code"); this.append(text, request, "message"); this.append(text, request, "exception_type"); this.append(text, request, "request_uri"); final ServletContext ctx = this.getServletContext(); text.append(Logger.format("servlet context path: \"%s\"\n", request.getContextPath())); text.append( Logger.format( "requested: %s (%s) at %s:%d\n", request.getRequestURL().toString(), request.getMethod(), request.getServerName(), request.getServerPort())); text.append( Logger.format( "request: %s, %d bytes\n", request.getContentType(), request.getContentLength())); text.append( Logger.format( "remote: %s:%d (%s)\n", request.getRemoteAddr(), request.getRemotePort(), request.getRemoteHost())); text.append( Logger.format( "servlet: \"%s\" (API %d.%d) at \"%s\"\n", ctx.getServletContextName(), ctx.getMajorVersion(), ctx.getMinorVersion(), ctx.getServerInfo())); text.append("headers:\n").append(ExceptionTrap.headers(request)).append('\n'); text.append( Logger.format( "exception: %[exception]s\n", request.getAttribute("javax.servlet.error.exception"))); return text; }
protected void setLoggingDir(Properties props, ServletContext servletContext) { // Don't use the default here - we need to know whether the property was overridden. String loggingDirName = System.getProperty(CoreConfiguration.CORE_LOGGING_DIR_KEY); if (loggingDirName != null) { System.out.println( CoreConfiguration.CORE_LOGGING_DIR_KEY + " property overridden with '" + loggingDirName + "'."); } else { loggingDirName = CoreConfiguration.CORE_LOGGING_DIR_DEFAULT; String serverInfo = servletContext.getServerInfo(); if (serverInfo.matches("(?s)(?i).*Tomcat.*")) { loggingDirName = CoreConfiguration.CORE_TOMCAT_LOGGING_DIR_DEFAULT; } else if (serverInfo.matches("(?s)(?i).*Jetty.*")) { loggingDirName = CoreConfiguration.CORE_JETTY_LOGGING_DIR_DEFAULT; } props.setProperty(CoreConfiguration.CORE_LOGGING_DIR_KEY, loggingDirName); System.out.println( "Setting " + CoreConfiguration.CORE_LOGGING_DIR_KEY + " property to " + props.getProperty(CoreConfiguration.CORE_LOGGING_DIR_KEY) + ", based on servlet container type."); } }
@Override public String getServerInfo() { return proxy.getServerInfo(); }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, false, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); out = pageContext.getOut(); _jspx_out = out; out.write("<!--\n"); out.write(" Licensed to the Apache Software Foundation (ASF) under one or more\n"); out.write(" contributor license agreements. See the NOTICE file distributed with\n"); out.write(" this work for additional information regarding copyright ownership.\n"); out.write(" The ASF licenses this file to You under the Apache License, Version 2.0\n"); out.write(" (the \"License\"); you may not use this file except in compliance with\n"); out.write(" the License. You may obtain a copy of the License at\n"); out.write("\n"); out.write(" http://www.apache.org/licenses/LICENSE-2.0\n"); out.write("\n"); out.write(" Unless required by applicable law or agreed to in writing, software\n"); out.write(" distributed under the License is distributed on an \"AS IS\" BASIS,\n"); out.write(" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"); out.write(" See the License for the specific language governing permissions and\n"); out.write(" limitations under the License.\n"); out.write("-->\n"); out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"); out.write(" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"); out.write("\n"); out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"); out.write(" <head>\n"); out.write(" <title>"); out.print(application.getServerInfo()); out.write("</title>\n"); out.write(" <style type=\"text/css\">\n"); out.write(" /*<![CDATA[*/\n"); out.write(" body {\n"); out.write(" color: #000000;\n"); out.write(" background-color: #FFFFFF;\n"); out.write("\t font-family: Arial, \"Times New Roman\", Times, serif;\n"); out.write(" margin: 10px 0px;\n"); out.write(" }\n"); out.write("\n"); out.write(" img {\n"); out.write(" border: none;\n"); out.write(" }\n"); out.write(" \n"); out.write(" a:link, a:visited {\n"); out.write(" color: blue\n"); out.write(" }\n"); out.write("\n"); out.write(" th {\n"); out.write(" font-family: Verdana, \"Times New Roman\", Times, serif;\n"); out.write(" font-size: 110%;\n"); out.write(" font-weight: normal;\n"); out.write(" font-style: italic;\n"); out.write(" background: #D2A41C;\n"); out.write(" text-align: left;\n"); out.write(" }\n"); out.write("\n"); out.write(" td {\n"); out.write(" color: #000000;\n"); out.write("\tfont-family: Arial, Helvetica, sans-serif;\n"); out.write(" }\n"); out.write(" \n"); out.write(" td.menu {\n"); out.write(" background: #FFDC75;\n"); out.write(" }\n"); out.write("\n"); out.write(" .center {\n"); out.write(" text-align: center;\n"); out.write(" }\n"); out.write("\n"); out.write(" .code {\n"); out.write(" color: #000000;\n"); out.write(" font-family: \"Courier New\", Courier, monospace;\n"); out.write(" font-size: 110%;\n"); out.write(" margin-left: 2.5em;\n"); out.write(" }\n"); out.write(" \n"); out.write(" #banner {\n"); out.write(" margin-bottom: 12px;\n"); out.write(" }\n"); out.write("\n"); out.write(" p#congrats {\n"); out.write(" margin-top: 0;\n"); out.write(" font-weight: bold;\n"); out.write(" text-align: center;\n"); out.write(" }\n"); out.write("\n"); out.write(" p#footer {\n"); out.write(" text-align: right;\n"); out.write(" font-size: 80%;\n"); out.write(" }\n"); out.write(" /*]]>*/\n"); out.write(" </style>\n"); out.write("</head>\n"); out.write("\n"); out.write("<body>\n"); out.write("\n"); out.write("<!-- Header -->\n"); out.write("<table id=\"banner\" width=\"100%\">\n"); out.write(" <tr>\n"); out.write(" <td align=\"left\" style=\"width:130px\">\n"); out.write(" <a href=\"http://tomcat.apache.org/\">\n"); out.write( "\t <img src=\"tomcat.gif\" height=\"92\" width=\"130\" alt=\"The Mighty Tomcat - MEOW!\"/>\n"); out.write("\t</a>\n"); out.write(" </td>\n"); out.write(" <td align=\"left\" valign=\"top\"><b>"); out.print(application.getServerInfo()); out.write("</b></td>\n"); out.write(" <td align=\"right\">\n"); out.write(" <a href=\"http://www.apache.org/\">\n"); out.write( "\t <img src=\"asf-logo-wide.gif\" height=\"51\" width=\"537\" alt=\"The Apache Software Foundation\"/>\n"); out.write("\t</a>\n"); out.write(" </td>\n"); out.write(" </tr>\n"); out.write("</table>\n"); out.write("\n"); out.write("<table>\n"); out.write(" <tr>\n"); out.write("\n"); out.write(" <!-- Table of Contents -->\n"); out.write(" <td valign=\"top\">\n"); out.write( " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"); out.write(" <tr>\n"); out.write("\t\t <th>Administration</th>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write("\t\t <td class=\"menu\">\n"); out.write("\t\t <a href=\"manager/status\">Status</a><br/>\n"); out.write( " <!--<a href=\"admin\">Tomcat Administration</a><br/>-->\n"); out.write(" <a href=\"manager/html\">Tomcat Manager</a><br/>\n"); out.write(" \n"); out.write(" </td>\n"); out.write(" </tr>\n"); out.write(" </table>\n"); out.write("\n"); out.write("\t <br />\n"); out.write( " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"); out.write(" <tr>\n"); out.write("\t\t <th>Documentation</th>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write(" <td class=\"menu\">\n"); out.write(" <a href=\"RELEASE-NOTES.txt\">Release Notes</a><br/>\n"); out.write(" <a href=\"docs/changelog.html\">Change Log</a><br/>\n"); out.write( " <a href=\"docs\">Tomcat Documentation</a><br/> \n"); out.write(" \n"); out.write("\t\t </td>\n"); out.write(" </tr>\n"); out.write(" </table>\n"); out.write("\t \n"); out.write(" <br/>\n"); out.write( " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"); out.write(" <tr>\n"); out.write(" <th>Tomcat Online</th>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write(" <td class=\"menu\">\n"); out.write( " <a href=\"http://tomcat.apache.org/\">Home Page</a><br/>\n"); out.write("\t\t <a href=\"http://tomcat.apache.org/faq/\">FAQ</a><br/>\n"); out.write( " <a href=\"http://tomcat.apache.org/bugreport.html\">Bug Database</a><br/>\n"); out.write( " <a href=\"http://issues.apache.org/bugzilla/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=RESOLVED&resolution=LATER&resolution=REMIND&resolution=---&bugidtype=include&product=Tomcat+5&cmdtype=doit&order=Importance\">Open Bugs</a><br/>\n"); out.write( " <a href=\"http://mail-archives.apache.org/mod_mbox/tomcat-users/\">Users Mailing List</a><br/>\n"); out.write( " <a href=\"http://mail-archives.apache.org/mod_mbox/tomcat-dev/\">Developers Mailing List</a><br/>\n"); out.write(" <a href=\"irc://irc.freenode.net/#tomcat\">IRC</a><br/>\n"); out.write("\t\t \n"); out.write(" </td>\n"); out.write(" </tr>\n"); out.write(" </table>\n"); out.write("\t \n"); out.write(" <br/>\n"); out.write( " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"); out.write(" <tr>\n"); out.write(" <th>Examples</th>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write(" <td class=\"menu\">\n"); out.write(" <a href=\"examples/servlets/\">Servlets Examples</a><br/>\n"); out.write(" <a href=\"examples/jsp/\">JSP Examples</a><br/>\n"); out.write(" <a href=\"webdav/\">WebDAV capabilities</a><br/>\n"); out.write(" \t\t \n"); out.write(" </td>\n"); out.write(" </tr>\n"); out.write(" </table>\n"); out.write("\t \n"); out.write(" <br/>\n"); out.write( " <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"); out.write(" <tr>\n"); out.write("\t\t <th>Miscellaneous</th>\n"); out.write(" </tr>\n"); out.write(" <tr>\n"); out.write(" <td class=\"menu\">\n"); out.write( " <a href=\"http://java.sun.com/products/jsp\">Sun's Java Server Pages Site</a><br/>\n"); out.write( " <a href=\"http://java.sun.com/products/servlet\">Sun's Servlet Site</a><br/>\n"); out.write(" \t\t \n"); out.write(" </td>\n"); out.write(" </tr>\n"); out.write(" </table>\n"); out.write(" </td>\n"); out.write("\n"); out.write(" <td style=\"width:20px\"> </td>\n"); out.write("\t\n"); out.write(" <!-- Body -->\n"); out.write(" <td align=\"left\" valign=\"top\">\n"); out.write( " <p id=\"congrats\">If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!</p>\n"); out.write(" \n"); out.write( " <p>As you may have guessed by now, this is the default Tomcat home page. It can be found on the local filesystem at:</p>\n"); out.write(" <p class=\"code\">$CATALINA_HOME/webapps/ROOT/index.jsp</p>\n"); out.write("\t \n"); out.write( " <p>where \"$CATALINA_HOME\" is the root of the Tomcat installation directory. If you're seeing this page, and you don't think you should be, then you're either a user who has arrived at new installation of Tomcat, or you're an administrator who hasn't got his/her setup quite right. Providing the latter is the case, please refer to the <a href=\"docs\">Tomcat Documentation</a> for more detailed setup and administration information than is found in the INSTALL file.</p>\n"); out.write("\n"); out.write(" <p><b>NOTE: For security reasons, using the manager webapp\n"); out.write(" is restricted to users with role \"manager\".</b>\n"); out.write( " Users are defined in <code>$CATALINA_HOME/conf/tomcat-users.xml</code>.</p>\n"); out.write("\n"); out.write( " <p>Included with this release are a host of sample Servlets and JSPs (with associated source code), extensive documentation, and an introductory guide to developing web applications.</p>\n"); out.write("\n"); out.write( " <p>Tomcat mailing lists are available at the Tomcat project web site:</p>\n"); out.write("\n"); out.write(" <ul>\n"); out.write( " <li><b><a href=\"mailto:[email protected]\">[email protected]</a></b> for general questions related to configuring and using Tomcat</li>\n"); out.write( " <li><b><a href=\"mailto:[email protected]\">[email protected]</a></b> for developers working on Tomcat</li>\n"); out.write(" </ul>\n"); out.write("\n"); out.write(" <p>Thanks for using Tomcat!</p>\n"); out.write("\n"); out.write( " <p id=\"footer\"><img src=\"tomcat-power.gif\" width=\"77\" height=\"80\" alt=\"Powered by Tomcat\"/><br/>\n"); out.write("\t \n"); out.write("\n"); out.write("\t Copyright © 1999-2011 Apache Software Foundation<br/>\n"); out.write(" All Rights Reserved\n"); out.write(" </p>\n"); out.write(" </td>\n"); out.write("\n"); out.write(" </tr>\n"); out.write("</table>\n"); out.write("\n"); out.write("</body>\n"); out.write("</html>\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
@Override public String getServerInfo() { return sc.getServerInfo(); }
public String getServerInfo() { return servletContext.getServerInfo(); }
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { super.contextInitialized(servletContextEvent); /* * -------------------------------------------------------------------- * Archaius Configuration Settings * -------------------------------------------------------------------- */ Env env = Env.getEnvironment(); if (env == Env.ALL) { ConfigurationManager.getDeploymentContext().setDeploymentEnvironment("CHOP"); LOG.info("Setting environment to: CHOP"); } else if (env == Env.UNIT) { LOG.info("Operating in UNIT environment"); } try { ConfigurationManager.loadCascadedPropertiesFromResources("project"); } catch (IOException e) { LOG.error("Failed to load project properties!", e); throw new RuntimeException("Cannot do much without properly loading our configuration.", e); } /* * -------------------------------------------------------------------- * Environment Based Configuration Property Adjustments * -------------------------------------------------------------------- */ servletFig = injector.getInstance(ServletFig.class); runner = injector.getInstance(Runner.class); project = injector.getInstance(Project.class); ServletContext context = servletContextEvent.getServletContext(); /* * -------------------------------------------------------------------- * Adjust Runner Settings to Environment * -------------------------------------------------------------------- */ if (env == Env.UNIT || env == Env.INTEG || env == Env.ALL) { runner.bypass(Runner.HOSTNAME_KEY, "localhost"); runner.bypass(Runner.IPV4_KEY, "127.0.0.1"); } else if (env == Env.CHOP) { Ec2Metadata.applyBypass(runner); } StringBuilder sb = new StringBuilder(); sb.append("https://") .append(runner.getHostname()) .append(':') .append(runner.getServerPort()) .append(context.getContextPath()); String baseUrl = sb.toString(); runner.bypass(Runner.URL_KEY, baseUrl); LOG.info("Setting url key {} to base url {}", Runner.URL_KEY, baseUrl); File tempDir = new File(System.getProperties().getProperty("java.io.tmpdir")); runner.bypass(Runner.RUNNER_TEMP_DIR_KEY, tempDir.getAbsolutePath()); LOG.info( "Setting runner temp directory key {} to context temp directory {}", Runner.RUNNER_TEMP_DIR_KEY, tempDir.getAbsolutePath()); /* * -------------------------------------------------------------------- * Adjust ServletFig Settings to Environment * -------------------------------------------------------------------- */ servletFig.bypass(ServletFig.SERVER_INFO_KEY, context.getServerInfo()); LOG.info( "Setting server info key {} to {}", ServletFig.SERVER_INFO_KEY, context.getServerInfo()); servletFig.bypass(ServletFig.CONTEXT_PATH, context.getContextPath()); LOG.info( "Setting server context path key {} to {}", ServletFig.CONTEXT_PATH, context.getContextPath()); // @todo Is this necessary? servletFig.bypass(ServletFig.CONTEXT_TEMPDIR_KEY, tempDir.getAbsolutePath()); LOG.info( "Setting runner context temp directory key {} to context temp directory {}", ServletFig.CONTEXT_TEMPDIR_KEY, tempDir.getAbsolutePath()); /* * -------------------------------------------------------------------- * Start Up The RunnerRegistry and Register * -------------------------------------------------------------------- */ if (isTestMode()) { runner.bypass(Runner.HOSTNAME_KEY, "localhost"); runner.bypass(Runner.IPV4_KEY, "127.0.0.1"); project.bypass(Project.LOAD_KEY, "bogus-load-key"); project.bypass(Project.ARTIFACT_ID_KEY, "bogus-artifact-id"); project.bypass(Project.GROUP_ID_KEY, "org.apache.usergrid.chop"); project.bypass(Project.CHOP_VERSION_KEY, "bogus-chop-version"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); project.bypass(Project.CREATE_TIMESTAMP_KEY, dateFormat.format(new Date())); project.bypass( Project.GIT_URL_KEY, "http://stash.safehaus.org/projects/CHOP/repos/main/browse"); project.bypass(Project.GIT_UUID_KEY, "d637a8ce"); project.bypass(Project.LOAD_TIME_KEY, dateFormat.format(new Date())); project.bypass(Project.PROJECT_VERSION_KEY, "1.0.0-SNAPSHOT"); } if (runner.getHostname() != null && project.getLoadKey() != null) { final RunnerRegistry registry = getInjector().getInstance(RunnerRegistry.class); if (env != Env.TEST && env != Env.UNIT) { registry.register(runner); registered = true; Runtime.getRuntime() .addShutdownHook( new Thread( new Runnable() { @Override public void run() { if (registered) { System.err.println( "Premature shutdown, attempting to unregister this runner."); registry.unregister(runner); LOG.info("Unregistering runner on shutdownx: {}", runner.getHostname()); registered = false; } } })); LOG.info("Registered runner information in coordinator registry."); } else { LOG.warn("Env = {} so we are not registering this runner.", env); } } else { LOG.warn( "Runner registry not started, and not registered: insufficient configuration parameters."); } }
public String getServerInfo() { return delegate.getServerInfo(); }