Search in sources :

Example 36 with Manager

use of org.apache.catalina.Manager in project tomcat70 by apache.

the class Request method isRequestedSessionIdValid.

/**
 * Return <code>true</code> if the session identifier included in this
 * request identifies a valid session.
 */
@Override
public boolean isRequestedSessionIdValid() {
    if (requestedSessionId == null) {
        return false;
    }
    if (context == null) {
        return false;
    }
    Manager manager = context.getManager();
    if (manager == null) {
        return false;
    }
    Session session = null;
    try {
        session = manager.findSession(requestedSessionId);
    } catch (IOException e) {
    // Can't find the session
    }
    if ((session == null) || !session.isValid()) {
        // Check for parallel deployment contexts
        if (getMappingData().contexts == null) {
            return false;
        } else {
            for (int i = (getMappingData().contexts.length); i > 0; i--) {
                Context ctxt = (Context) getMappingData().contexts[i - 1];
                try {
                    if (ctxt.getManager().findSession(requestedSessionId) != null) {
                        return true;
                    }
                } catch (IOException e) {
                // Ignore
                }
            }
            return false;
        }
    }
    return true;
}
Also used : ServletRequestContext(org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext) AsyncContext(javax.servlet.AsyncContext) Context(org.apache.catalina.Context) ServletContext(javax.servlet.ServletContext) IOException(java.io.IOException) StringManager(org.apache.tomcat.util.res.StringManager) Manager(org.apache.catalina.Manager) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.catalina.Session)

Example 37 with Manager

use of org.apache.catalina.Manager in project tomcat70 by apache.

the class StandardContext method startInternal.

/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    if (log.isDebugEnabled())
        log.debug("Starting " + getBaseName());
    // Send j2ee.state.starting notification
    if (this.getObjectName() != null) {
        Notification notification = new Notification("j2ee.state.starting", this.getObjectName(), sequenceNumber.getAndIncrement());
        broadcaster.sendNotification(notification);
    }
    setConfigured(false);
    boolean ok = true;
    // ensure the NamingResources follows the correct lifecycle
    if (namingResources != null) {
        namingResources.start();
    }
    // Add missing components as necessary
    if (webappResources == null) {
        // (1) Required by Loader
        if (log.isDebugEnabled())
            log.debug("Configuring default Resources");
        try {
            String docBase = getDocBase();
            if (docBase == null) {
                setResources(new EmptyDirContext());
            } else if (docBase.endsWith(".war") && !(new File(getBasePath())).isDirectory()) {
                setResources(new WARDirContext());
            } else {
                setResources(new FileDirContext());
            }
        } catch (IllegalArgumentException e) {
            log.error(sm.getString("standardContext.resourcesInit"), e);
            ok = false;
        }
    }
    if (ok) {
        if (!resourcesStart()) {
            throw new LifecycleException("Error in resourceStart()");
        }
    }
    if (getLoader() == null) {
        WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
        webappLoader.setDelegate(getDelegate());
        setLoader(webappLoader);
    }
    // Initialize character set mapper
    getCharsetMapper();
    // Post work directory
    postWorkDirectory();
    // Validate required extensions
    boolean dependencyCheck = true;
    try {
        dependencyCheck = ExtensionValidator.validateApplication(getResources(), this);
    } catch (IOException ioe) {
        log.error(sm.getString("standardContext.extensionValidationError"), ioe);
        dependencyCheck = false;
    }
    if (!dependencyCheck) {
        // do not make application available if dependency check fails
        ok = false;
    }
    // Reading the "catalina.useNaming" environment variable
    String useNamingProperty = System.getProperty("catalina.useNaming");
    if ((useNamingProperty != null) && (useNamingProperty.equals("false"))) {
        useNaming = false;
    }
    if (ok && isUseNaming()) {
        if (getNamingContextListener() == null) {
            NamingContextListener ncl = new NamingContextListener();
            ncl.setName(getNamingContextName());
            ncl.setExceptionOnFailedWrite(getJndiExceptionOnFailedWrite());
            addLifecycleListener(ncl);
            setNamingContextListener(ncl);
        }
    }
    // Standard container startup
    if (log.isDebugEnabled())
        log.debug("Processing standard container startup");
    // Binding thread
    ClassLoader oldCCL = bindThread();
    try {
        if (ok) {
            // Start our subordinate components, if any
            Loader loader = getLoaderInternal();
            if ((loader != null) && (loader instanceof Lifecycle))
                ((Lifecycle) loader).start();
            // since the loader just started, the webapp classloader is now
            // created.
            // By calling unbindThread and bindThread in a row, we setup the
            // current Thread CCL to be the webapp classloader
            unbindThread(oldCCL);
            oldCCL = bindThread();
            // Initialize logger again. Other components might have used it
            // too early, so it should be reset.
            logger = null;
            getLogger();
            Cluster cluster = getClusterInternal();
            if ((cluster != null) && (cluster instanceof Lifecycle))
                ((Lifecycle) cluster).start();
            Realm realm = getRealmInternal();
            if ((realm != null) && (realm instanceof Lifecycle))
                ((Lifecycle) realm).start();
            DirContext resources = getResourcesInternal();
            if ((resources != null) && (resources instanceof Lifecycle))
                ((Lifecycle) resources).start();
            // Notify our interested LifecycleListeners
            fireLifecycleEvent(Lifecycle.CONFIGURE_START_EVENT, null);
            // Start our child containers, if not already started
            for (Container child : findChildren()) {
                if (!child.getState().isAvailable()) {
                    child.start();
                }
            }
            // if any
            if (pipeline instanceof Lifecycle) {
                ((Lifecycle) pipeline).start();
            }
            // Acquire clustered manager
            Manager contextManager = null;
            Manager manager = getManagerInternal();
            if (manager == null) {
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString("standardContext.cluster.noManager", Boolean.valueOf((getCluster() != null)), Boolean.valueOf(distributable)));
                }
                if ((getCluster() != null) && distributable) {
                    try {
                        contextManager = getCluster().createManager(getName());
                    } catch (Exception ex) {
                        log.error("standardContext.clusterFail", ex);
                        ok = false;
                    }
                } else {
                    contextManager = new StandardManager();
                }
                manager = contextManager;
            }
            // Configure default manager if none was specified
            if (contextManager != null) {
                if (log.isDebugEnabled()) {
                    log.debug(sm.getString("standardContext.manager", contextManager.getClass().getName()));
                }
                setManager(contextManager);
            }
            if (manager != null && (getCluster() != null) && distributable) {
                // let the cluster know that there is a context that is distributable
                // and that it has its own manager
                getCluster().registerManager(manager);
            }
        }
    } finally {
        // Unbinding thread
        unbindThread(oldCCL);
    }
    if (!getConfigured()) {
        log.error(sm.getString("standardContext.configurationFail"));
        ok = false;
    }
    // We put the resources into the servlet context
    if (ok)
        getServletContext().setAttribute(Globals.RESOURCES_ATTR, getResources());
    // Initialize associated mapper
    mapper.setContext(getPath(), welcomeFiles, getResources());
    // Binding thread
    oldCCL = bindThread();
    if (ok) {
        if (getInstanceManager() == null) {
            javax.naming.Context context = null;
            if (isUseNaming() && getNamingContextListener() != null) {
                context = getNamingContextListener().getEnvContext();
            }
            Map<String, Map<String, String>> injectionMap = buildInjectionMap(getIgnoreAnnotations() ? new NamingResources() : getNamingResources());
            setInstanceManager(new DefaultInstanceManager(context, injectionMap, this, this.getClass().getClassLoader()));
            getServletContext().setAttribute(InstanceManager.class.getName(), getInstanceManager());
        }
    }
    try {
        // Create context attributes that will be required
        if (ok) {
            getServletContext().setAttribute(JarScanner.class.getName(), getJarScanner());
        }
        // Set up the context init params
        mergeParameters();
        // Call ServletContainerInitializers
        for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry : initializers.entrySet()) {
            try {
                entry.getKey().onStartup(entry.getValue(), getServletContext());
            } catch (ServletException e) {
                log.error(sm.getString("standardContext.sciFail"), e);
                ok = false;
                break;
            }
        }
        // Configure and call application event listeners
        if (ok) {
            if (!listenerStart()) {
                log.error(sm.getString("standardContext.listenerFail"));
                ok = false;
            }
        }
        try {
            // Start manager
            Manager manager = getManagerInternal();
            if ((manager != null) && (manager instanceof Lifecycle)) {
                ((Lifecycle) getManager()).start();
            }
        } catch (Exception e) {
            log.error(sm.getString("standardContext.managerFail"), e);
            ok = false;
        }
        // Configure and call application filters
        if (ok) {
            if (!filterStart()) {
                log.error(sm.getString("standardContext.filterFail"));
                ok = false;
            }
        }
        // Load and initialize all "load on startup" servlets
        if (ok) {
            if (!loadOnStartup(findChildren())) {
                log.error(sm.getString("standardContext.servletFail"));
                ok = false;
            }
        }
        // Start ContainerBackgroundProcessor thread
        super.threadStart();
    } finally {
        // Unbinding thread
        unbindThread(oldCCL);
    }
    // Set available status depending upon startup success
    if (ok) {
        if (log.isDebugEnabled())
            log.debug("Starting completed");
    } else {
        log.error(sm.getString("standardContext.startFailed", getName()));
    }
    startTime = System.currentTimeMillis();
    // Send j2ee.state.running notification
    if (ok && (this.getObjectName() != null)) {
        Notification notification = new Notification("j2ee.state.running", this.getObjectName(), sequenceNumber.getAndIncrement());
        broadcaster.sendNotification(notification);
    }
    // of files on startup
    if (getLoader() instanceof WebappLoader) {
        ((WebappLoader) getLoader()).closeJARs(true);
    }
    // Reinitializing if something went wrong
    if (!ok) {
        setState(LifecycleState.FAILED);
    } else {
        setState(LifecycleState.STARTING);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) FileDirContext(org.apache.naming.resources.FileDirContext) InstanceManager(org.apache.tomcat.InstanceManager) NamingResources(org.apache.catalina.deploy.NamingResources) WebappLoader(org.apache.catalina.loader.WebappLoader) Loader(org.apache.catalina.Loader) WARDirContext(org.apache.naming.resources.WARDirContext) BaseDirContext(org.apache.naming.resources.BaseDirContext) EmptyDirContext(org.apache.naming.resources.EmptyDirContext) ProxyDirContext(org.apache.naming.resources.ProxyDirContext) DirContext(javax.naming.directory.DirContext) FileDirContext(org.apache.naming.resources.FileDirContext) Manager(org.apache.catalina.Manager) InstanceManager(org.apache.tomcat.InstanceManager) StandardManager(org.apache.catalina.session.StandardManager) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) JarScanner(org.apache.tomcat.JarScanner) Notification(javax.management.Notification) ServletContainerInitializer(javax.servlet.ServletContainerInitializer) ServletException(javax.servlet.ServletException) Container(org.apache.catalina.Container) Realm(org.apache.catalina.Realm) LifecycleException(org.apache.catalina.LifecycleException) WARDirContext(org.apache.naming.resources.WARDirContext) Lifecycle(org.apache.catalina.Lifecycle) StandardManager(org.apache.catalina.session.StandardManager) EmptyDirContext(org.apache.naming.resources.EmptyDirContext) Cluster(org.apache.catalina.Cluster) IOException(java.io.IOException) LifecycleException(org.apache.catalina.LifecycleException) ListenerNotFoundException(javax.management.ListenerNotFoundException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) NamingException(javax.naming.NamingException) MalformedURLException(java.net.MalformedURLException) WebappLoader(org.apache.catalina.loader.WebappLoader) File(java.io.File) FilterMap(org.apache.catalina.deploy.FilterMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 38 with Manager

use of org.apache.catalina.Manager in project tomcat70 by apache.

the class ApplicationHttpRequest method isRequestedSessionIdValid.

/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 */
@Override
public boolean isRequestedSessionIdValid() {
    if (crossContext) {
        String requestedSessionId = getRequestedSessionId();
        if (requestedSessionId == null)
            return (false);
        if (context == null)
            return (false);
        Manager manager = context.getManager();
        if (manager == null)
            return (false);
        Session session = null;
        try {
            session = manager.findSession(requestedSessionId);
        } catch (IOException e) {
        // Ignore
        }
        if ((session != null) && session.isValid()) {
            return (true);
        } else {
            return (false);
        }
    } else {
        return super.isRequestedSessionIdValid();
    }
}
Also used : IOException(java.io.IOException) Manager(org.apache.catalina.Manager) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.catalina.Session)

Example 39 with Manager

use of org.apache.catalina.Manager in project tomcat70 by apache.

the class SingleSignOn method expire.

private void expire(SingleSignOnSessionKey key) {
    if (engine == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.engineNull", key));
        return;
    }
    Container host = engine.findChild(key.getHostName());
    if (host == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.hostNotFound", key));
        return;
    }
    Context context = (Context) host.findChild(key.getContextName());
    if (context == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.contextNotFound", key));
        return;
    }
    Manager manager = context.getManager();
    if (manager == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerNotFound", key));
        return;
    }
    Session session = null;
    try {
        session = manager.findSession(key.getSessionId());
    } catch (IOException e) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerError", key), e);
        return;
    }
    if (session == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.sessionNotFound", key));
        return;
    }
    session.expire();
}
Also used : Context(org.apache.catalina.Context) Container(org.apache.catalina.Container) IOException(java.io.IOException) StringManager(org.apache.tomcat.util.res.StringManager) Manager(org.apache.catalina.Manager) Session(org.apache.catalina.Session)

Example 40 with Manager

use of org.apache.catalina.Manager in project tomcat70 by apache.

the class HTMLManagerServlet method list.

/**
 * Render a HTML list of the currently active Contexts in our virtual host,
 * and memory and server status information.
 *
 * @param request The request
 * @param response The response
 * @param message a message to display
 */
protected void list(HttpServletRequest request, HttpServletResponse response, String message, StringManager smClient) throws IOException {
    if (debug >= 1)
        log("list: Listing contexts for virtual host '" + host.getName() + "'");
    PrintWriter writer = response.getWriter();
    // HTML Header Section
    writer.print(Constants.HTML_HEADER_SECTION);
    // Body Header Section
    Object[] args = new Object[2];
    args[0] = request.getContextPath();
    args[1] = smClient.getString("htmlManagerServlet.title");
    writer.print(MessageFormat.format(Constants.BODY_HEADER_SECTION, args));
    // Message Section
    args = new Object[3];
    args[0] = smClient.getString("htmlManagerServlet.messageLabel");
    if (message == null || message.length() == 0) {
        args[1] = "OK";
    } else {
        args[1] = RequestUtil.filter(message);
    }
    writer.print(MessageFormat.format(Constants.MESSAGE_SECTION, args));
    // Manager Section
    args = new Object[9];
    args[0] = smClient.getString("htmlManagerServlet.manager");
    args[1] = response.encodeURL(request.getContextPath() + "/html/list");
    args[2] = smClient.getString("htmlManagerServlet.list");
    args[3] = response.encodeURL(request.getContextPath() + "/" + smClient.getString("htmlManagerServlet.helpHtmlManagerFile"));
    args[4] = smClient.getString("htmlManagerServlet.helpHtmlManager");
    args[5] = response.encodeURL(request.getContextPath() + "/" + smClient.getString("htmlManagerServlet.helpManagerFile"));
    args[6] = smClient.getString("htmlManagerServlet.helpManager");
    args[7] = response.encodeURL(request.getContextPath() + "/status");
    args[8] = smClient.getString("statusServlet.title");
    writer.print(MessageFormat.format(Constants.MANAGER_SECTION, args));
    // Apps Header Section
    args = new Object[7];
    args[0] = smClient.getString("htmlManagerServlet.appsTitle");
    args[1] = smClient.getString("htmlManagerServlet.appsPath");
    args[2] = smClient.getString("htmlManagerServlet.appsVersion");
    args[3] = smClient.getString("htmlManagerServlet.appsName");
    args[4] = smClient.getString("htmlManagerServlet.appsAvailable");
    args[5] = smClient.getString("htmlManagerServlet.appsSessions");
    args[6] = smClient.getString("htmlManagerServlet.appsTasks");
    writer.print(MessageFormat.format(APPS_HEADER_SECTION, args));
    // Apps Row Section
    // Create sorted map of deployed applications by context name.
    Container[] children = host.findChildren();
    String[] contextNames = new String[children.length];
    for (int i = 0; i < children.length; i++) contextNames[i] = children[i].getName();
    Arrays.sort(contextNames);
    String appsStart = smClient.getString("htmlManagerServlet.appsStart");
    String appsStop = smClient.getString("htmlManagerServlet.appsStop");
    String appsReload = smClient.getString("htmlManagerServlet.appsReload");
    String appsUndeploy = smClient.getString("htmlManagerServlet.appsUndeploy");
    String appsExpire = smClient.getString("htmlManagerServlet.appsExpire");
    String noVersion = "<i>" + smClient.getString("htmlManagerServlet.noVersion") + "</i>";
    boolean isHighlighted = true;
    boolean isDeployed = true;
    String highlightColor = null;
    for (String contextName : contextNames) {
        Context ctxt = (Context) host.findChild(contextName);
        if (ctxt != null) {
            // Bugzilla 34818, alternating row colors
            isHighlighted = !isHighlighted;
            if (isHighlighted) {
                highlightColor = "#C3F3C3";
            } else {
                highlightColor = "#FFFFFF";
            }
            String contextPath = ctxt.getPath();
            String displayPath = contextPath;
            if (displayPath.equals("")) {
                displayPath = "/";
            }
            StringBuilder tmp = new StringBuilder();
            tmp.append("path=");
            tmp.append(URLEncoder.DEFAULT.encode(displayPath, "UTF-8"));
            if (ctxt.getWebappVersion().length() > 0) {
                tmp.append("&version=");
                tmp.append(URLEncoder.DEFAULT.encode(ctxt.getWebappVersion(), "UTF-8"));
            }
            String pathVersion = tmp.toString();
            try {
                isDeployed = isDeployed(contextName);
            } catch (Exception e) {
                // Assume false on failure for safety
                isDeployed = false;
            }
            args = new Object[7];
            args[0] = "<a href=\"" + URLEncoder.DEFAULT.encode(contextPath + "/", "UTF-8") + "\">" + RequestUtil.filter(displayPath) + "</a>";
            if ("".equals(ctxt.getWebappVersion())) {
                args[1] = noVersion;
            } else {
                args[1] = RequestUtil.filter(ctxt.getWebappVersion());
            }
            if (ctxt.getDisplayName() == null) {
                args[2] = "&nbsp;";
            } else {
                args[2] = RequestUtil.filter(ctxt.getDisplayName());
            }
            args[3] = Boolean.valueOf(ctxt.getState().isAvailable());
            args[4] = RequestUtil.filter(response.encodeURL(request.getContextPath() + "/html/sessions?" + pathVersion));
            Manager manager = ctxt.getManager();
            if (manager instanceof DistributedManager && showProxySessions) {
                args[5] = Integer.valueOf(((DistributedManager) manager).getActiveSessionsFull());
            } else if (manager != null) {
                args[5] = Integer.valueOf(manager.getActiveSessions());
            } else {
                args[5] = Integer.valueOf(0);
            }
            args[6] = highlightColor;
            writer.print(MessageFormat.format(APPS_ROW_DETAILS_SECTION, args));
            args = new Object[14];
            args[0] = RequestUtil.filter(response.encodeURL(request.getContextPath() + "/html/start?" + pathVersion));
            args[1] = appsStart;
            args[2] = RequestUtil.filter(response.encodeURL(request.getContextPath() + "/html/stop?" + pathVersion));
            args[3] = appsStop;
            args[4] = RequestUtil.filter(response.encodeURL(request.getContextPath() + "/html/reload?" + pathVersion));
            args[5] = appsReload;
            args[6] = RequestUtil.filter(response.encodeURL(request.getContextPath() + "/html/undeploy?" + pathVersion));
            args[7] = appsUndeploy;
            args[8] = RequestUtil.filter(response.encodeURL(request.getContextPath() + "/html/expire?" + pathVersion));
            args[9] = appsExpire;
            args[10] = smClient.getString("htmlManagerServlet.expire.explain");
            if (manager == null) {
                args[11] = smClient.getString("htmlManagerServlet.noManager");
            } else {
                args[11] = Integer.valueOf(ctxt.getSessionTimeout());
            }
            args[12] = smClient.getString("htmlManagerServlet.expire.unit");
            args[13] = highlightColor;
            if (ctxt.getName().equals(this.context.getName())) {
                writer.print(MessageFormat.format(MANAGER_APP_ROW_BUTTON_SECTION, args));
            } else if (ctxt.getState().isAvailable() && isDeployed) {
                writer.print(MessageFormat.format(STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
            } else if (ctxt.getState().isAvailable() && !isDeployed) {
                writer.print(MessageFormat.format(STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
            } else if (!ctxt.getState().isAvailable() && isDeployed) {
                writer.print(MessageFormat.format(STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
            } else {
                writer.print(MessageFormat.format(STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
            }
        }
    }
    // Deploy Section
    args = new Object[7];
    args[0] = smClient.getString("htmlManagerServlet.deployTitle");
    args[1] = smClient.getString("htmlManagerServlet.deployServer");
    args[2] = response.encodeURL(request.getContextPath() + "/html/deploy");
    args[3] = smClient.getString("htmlManagerServlet.deployPath");
    args[4] = smClient.getString("htmlManagerServlet.deployConfig");
    args[5] = smClient.getString("htmlManagerServlet.deployWar");
    args[6] = smClient.getString("htmlManagerServlet.deployButton");
    writer.print(MessageFormat.format(DEPLOY_SECTION, args));
    args = new Object[4];
    args[0] = smClient.getString("htmlManagerServlet.deployUpload");
    args[1] = response.encodeURL(request.getContextPath() + "/html/upload");
    args[2] = smClient.getString("htmlManagerServlet.deployUploadFile");
    args[3] = smClient.getString("htmlManagerServlet.deployButton");
    writer.print(MessageFormat.format(UPLOAD_SECTION, args));
    // Diagnostics section
    args = new Object[5];
    args[0] = smClient.getString("htmlManagerServlet.diagnosticsTitle");
    args[1] = smClient.getString("htmlManagerServlet.diagnosticsLeak");
    args[2] = response.encodeURL(request.getContextPath() + "/html/findleaks");
    args[3] = smClient.getString("htmlManagerServlet.diagnosticsLeakWarning");
    args[4] = smClient.getString("htmlManagerServlet.diagnosticsLeakButton");
    writer.print(MessageFormat.format(DIAGNOSTICS_SECTION, args));
    // Server Header Section
    args = new Object[9];
    args[0] = smClient.getString("htmlManagerServlet.serverTitle");
    args[1] = smClient.getString("htmlManagerServlet.serverVersion");
    args[2] = smClient.getString("htmlManagerServlet.serverJVMVersion");
    args[3] = smClient.getString("htmlManagerServlet.serverJVMVendor");
    args[4] = smClient.getString("htmlManagerServlet.serverOSName");
    args[5] = smClient.getString("htmlManagerServlet.serverOSVersion");
    args[6] = smClient.getString("htmlManagerServlet.serverOSArch");
    args[7] = smClient.getString("htmlManagerServlet.serverHostname");
    args[8] = smClient.getString("htmlManagerServlet.serverIPAddress");
    writer.print(MessageFormat.format(Constants.SERVER_HEADER_SECTION, args));
    // Server Row Section
    args = new Object[8];
    args[0] = ServerInfo.getServerInfo();
    args[1] = System.getProperty("java.runtime.version");
    args[2] = System.getProperty("java.vm.vendor");
    args[3] = System.getProperty("os.name");
    args[4] = System.getProperty("os.version");
    args[5] = System.getProperty("os.arch");
    try {
        InetAddress address = InetAddress.getLocalHost();
        args[6] = address.getHostName();
        args[7] = address.getHostAddress();
    } catch (UnknownHostException e) {
        args[6] = "-";
        args[7] = "-";
    }
    writer.print(MessageFormat.format(Constants.SERVER_ROW_SECTION, args));
    // HTML Tail Section
    writer.print(Constants.HTML_TAIL_SECTION);
    // Finish up the response
    writer.flush();
    writer.close();
}
Also used : Context(org.apache.catalina.Context) UnknownHostException(java.net.UnknownHostException) DistributedManager(org.apache.catalina.DistributedManager) StringManager(org.apache.tomcat.util.res.StringManager) Manager(org.apache.catalina.Manager) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) DistributedManager(org.apache.catalina.DistributedManager) Container(org.apache.catalina.Container) InetAddress(java.net.InetAddress) PrintWriter(java.io.PrintWriter)

Aggregations

Manager (org.apache.catalina.Manager)54 StringManager (org.apache.tomcat.util.res.StringManager)26 IOException (java.io.IOException)22 Session (org.apache.catalina.Session)22 Context (org.apache.catalina.Context)19 Container (org.apache.catalina.Container)13 LifecycleException (org.apache.catalina.LifecycleException)12 Lifecycle (org.apache.catalina.Lifecycle)11 Loader (org.apache.catalina.Loader)11 InstanceManager (org.apache.tomcat.InstanceManager)11 StandardManager (org.apache.catalina.session.StandardManager)10 Realm (org.apache.catalina.Realm)9 ServletException (javax.servlet.ServletException)7 ArrayList (java.util.ArrayList)6 NamingException (javax.naming.NamingException)6 Cluster (org.apache.catalina.Cluster)6 DistributedManager (org.apache.catalina.DistributedManager)6 StandardContext (org.apache.catalina.core.StandardContext)6 WebappLoader (org.apache.catalina.loader.WebappLoader)6 ServletException (jakarta.servlet.ServletException)5