glenn 2002/06/13 07:58:01 Modified: catalina/src/share/org/apache/catalina/servlets HTMLManagerServlet.java LocalStrings.properties Log: More improvements to HTMLManagerServlet, thanks to Malcolm Edgar Revision Changes Path 1.8 +166 -144 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/HTMLManagerServlet.java Index: HTMLManagerServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/HTMLManagerServlet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- HTMLManagerServlet.java 10 Jun 2002 19:19:23 -0000 1.7 +++ HTMLManagerServlet.java 13 Jun 2002 14:58:01 -0000 1.8 @@ -1,65 +1,65 @@ /* - * $Header$ - * $Revision$ - * $Date$ - * - * ==================================================================== - * - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact [EMAIL PROTECTED] - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - * - * [Additional notices, if required by prior licensing conditions] - * - */ +* $Header$ +* $Revision$ +* $Date$ +* +* ==================================================================== +* +* The Apache Software License, Version 1.1 +* +* Copyright (c) 1999 The Apache Software Foundation. All rights +* reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, if +* any, must include the following acknowlegement: +* "This product includes software developed by the +* Apache Software Foundation (http://www.apache.org/)." +* Alternately, this acknowlegement may appear in the software itself, +* if and wherever such third-party acknowlegements normally appear. +* +* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software +* Foundation" must not be used to endorse or promote products derived +* from this software without prior written permission. For written +* permission, please contact [EMAIL PROTECTED] +* +* 5. Products derived from this software may not be called "Apache" +* nor may "Apache" appear in their names without prior written +* permission of the Apache Group. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +* +* This software consists of voluntary contributions made by many +* individuals on behalf of the Apache Software Foundation. For more +* information on the Apache Software Foundation, please see +* <http://www.apache.org/>. +* +* [Additional notices, if required by prior licensing conditions] +* +*/ package org.apache.catalina.servlets; @@ -79,26 +79,26 @@ import org.apache.catalina.util.ServerInfo; /** - * Servlet that enables remote management of the web applications installed - * within the same virtual host as this web application is. Normally, this - * functionality will be protected by a security constraint in the web - * application deployment descriptor. However, this requirement can be - * relaxed during testing. - * <p> - * The difference between this <code>ManagerServlet</code> and this - * Servlet is that this Servlet prints out a HTML interface which - * makes it easier to administrate. - * <p> - * However if you use a software that parses the output of - * <code>ManagerServlet</code you won't be able to upgrade - * to this Servlet since the output are not in the - * same format ar from <code>ManagerServlet</code> - * - * @author Bip Thelin - * @author Malcolm Edgar - * @version $Revision$, $Date$ - * @see ManagerServlet - */ +* Servlet that enables remote management of the web applications installed +* within the same virtual host as this web application is. Normally, this +* functionality will be protected by a security constraint in the web +* application deployment descriptor. However, this requirement can be +* relaxed during testing. +* <p> +* The difference between this <code>ManagerServlet</code> and this +* Servlet is that this Servlet prints out a HTML interface which +* makes it easier to administrate. +* <p> +* However if you use a software that parses the output of +* <code>ManagerServlet</code you won't be able to upgrade +* to this Servlet since the output are not in the +* same format ar from <code>ManagerServlet</code> +* +* @author Bip Thelin +* @author Malcolm Edgar +* @version $Revision$, $Date$ +* @see ManagerServlet +*/ public final class HTMLManagerServlet extends ManagerServlet { @@ -169,13 +169,13 @@ protected void install(PrintWriter writer, String config, String path, String war) { - StringWriter stringWriter = new StringWriter(); + StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); super.install(printWriter, config, path, war); - + list(writer, stringWriter.toString()); - } + } /** * Render a HTML list of the currently active Contexts in our virtual host, @@ -197,20 +197,26 @@ Object[] args = new Object[1]; args[0] = sm.getString("htmlManagerServlet.title"); writer.print(MessageFormat.format(BODY_HEADER_SECTION, args)); - + + // Message Section + args = new Object[3]; + args[0] = sm.getString("htmlManagerServlet.messageLabel"); + args[1] = (message != null) ? message : ""; + writer.print(MessageFormat.format(MESSAGE_SECTION, args)); + // Apps Header Section args = new Object[5]; args[0] = sm.getString("htmlManagerServlet.appsTitle"); args[1] = sm.getString("htmlManagerServlet.appsPath"); args[2] = sm.getString("htmlManagerServlet.appsName"); args[3] = sm.getString("htmlManagerServlet.appsAvailable"); - args[4] = sm.getString("htmlManagerServlet.appsSessions"); + args[4] = sm.getString("htmlManagerServlet.appsSessions"); writer.print(MessageFormat.format(APPS_HEADER_SECTION, args)); // Apps Row Section // Create sorted map of deployed applications context paths. String contextPaths[] = deployer.findDeployedApps(); - + TreeMap sortedContextPathsMap = new TreeMap(); for (int i = 0; i < contextPaths.length; i++) { @@ -225,47 +231,52 @@ String appsStop = sm.getString("htmlManagerServlet.appsStop"); String appsReload = sm.getString("htmlManagerServlet.appsReload"); String appsRemove = sm.getString("htmlManagerServlet.appsRemove"); - + Iterator iterator = sortedContextPathsMap.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); + while (iterator.hasNext()) { + Map.Entry entry = (Map.Entry) iterator.next(); String displayPath = (String) entry.getKey(); String contextPath = (String) entry.getKey(); Context context = deployer.findDeployedApp(contextPath); - + if (context != null ) { - args = new Object[6]; + args = new Object[6]; args[0] = displayPath; args[1] = context.getDisplayName(); if (args[1] == null) { args[1] = " "; } - args[2] = new Boolean(context.getAvailable()); - args[3] = - new Integer(context.getManager().findSessions().length); + args[2] = new Boolean(context.getAvailable()); + args[3] = + new Integer(context.getManager().findSessions().length); writer.print (MessageFormat.format(APPS_ROW_DETAILS_SECTION, args)); - args = new Object[5]; + args = new Object[5]; args[0] = displayPath; args[1] = appsStart; args[2] = appsStop; args[3] = appsReload; - args[4] = appsRemove; - writer.print - (MessageFormat.format(APPS_ROW_BUTTON_SECTION, args)); + args[4] = appsRemove; + if (context.getAvailable()) { + writer.print(MessageFormat.format( + STARTED_APPS_ROW_BUTTON_SECTION, args)); + } else { + writer.print(MessageFormat.format( + STOPPED_APPS_ROW_BUTTON_SECTION, args)); + } } else if (displayPath.equals("/")) { - args = new Object[4]; + args = new Object[4]; args[0] = displayPath; args[1] = "ROOT"; args[2] = new Boolean(true); - args[3] = "-"; + args[3] = "-"; writer.print (MessageFormat.format(APPS_ROOT_ROW_SECTION, args)); } } - + // Install Section args = new Object[5]; args[0] = sm.getString("htmlManagerServlet.installTitle"); @@ -283,7 +294,7 @@ args[3] = sm.getString("htmlManagerServlet.serverJVMVendor"); args[4] = sm.getString("htmlManagerServlet.serverOSName"); args[5] = sm.getString("htmlManagerServlet.serverOSVersion"); - args[6] = sm.getString("htmlManagerServlet.serverOSArch"); + args[6] = sm.getString("htmlManagerServlet.serverOSArch"); writer.print(MessageFormat.format(SERVER_HEADER_SECTION, args)); // Server Row Section @@ -293,14 +304,11 @@ 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"); + args[5] = System.getProperty("os.arch"); writer.print(MessageFormat.format(SERVER_ROW_SECTION, args)); - - // Message Section - args = new Object[3]; - args[0] = sm.getString("htmlManagerServlet.messageLabel"); - args[1] = (message != null) ? message : ""; - writer.print(MessageFormat.format(MESSAGE_SECTION, args)); + + // HTML Tail Section + writer.print(HTML_TAIL_SECTION); } /** @@ -315,9 +323,9 @@ StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); - + super.reload(printWriter, path); - + list(writer, stringWriter.toString()); } @@ -331,11 +339,11 @@ */ protected void remove(PrintWriter writer, String path) { - StringWriter stringWriter = new StringWriter(); + StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); - + super.remove(printWriter, path); - + list(writer, stringWriter.toString()); } @@ -347,13 +355,13 @@ * @param writer Writer to render to * @param path Context path of the application to list session information for */ - public void sessions(PrintWriter writer, String path) { + public void sessions(PrintWriter writer, String path) { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); - + super.sessions(printWriter, path); - + list(writer, stringWriter.toString()); } @@ -367,11 +375,11 @@ */ public void start(PrintWriter writer, String path) { - StringWriter stringWriter = new StringWriter(); + StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); - + super.start(printWriter, path); - + list(writer, stringWriter.toString()); } @@ -385,18 +393,18 @@ */ protected void stop(PrintWriter writer, String path) { - StringWriter stringWriter = new StringWriter(); + StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); super.stop(printWriter, path); - + list(writer, stringWriter.toString()); } // ------------------------------------------------------ Private Constants // These HTML sections are broken in relatively small sections, because of - // limited number of subsitutions MessageFormat can process + // limited number of subsitutions MessageFormat can process // (maximium of 10). private static final String HTML_HEADER_SECTION = @@ -457,13 +465,11 @@ " } \n" + "</style> \n"; - private static final String BODY_HEADER_SECTION = + private static final String BODY_HEADER_SECTION = "<title>{0}</title> \n" + "</head> \n" + "\n" + "<body bgcolor=\"#FFFFFF\"> \n" + - "<form method=\"get\" action=\"install\"> \n" + - "<input type=\"hidden\" name=\"path\"> \n" + "\n" + "<table border=\"2\" cellspacing=\"0\" cellpadding=\"3\" " + "bordercolor=\"#000000\"> \n" + @@ -477,7 +483,16 @@ "<br> \n" + "\n"; - private static final String APPS_HEADER_SECTION = + private static final String MESSAGE_SECTION = + "<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"> \n" + + " <tr> \n" + + " <td class=\"row-left\"><small><b>{0}</b> {1}</small></td>\n" + + " </tr> \n" + + "</table> \n" + + "<br> \n" + + "\n"; + + private static final String APPS_HEADER_SECTION = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"> \n" + "<tr> \n" + " <td colspan=\"10\" class=\"title\">{0}</td> \n" + @@ -499,10 +514,10 @@ " <td class=\"row-center\">" + "<small><a href=\"sessions?path={0}\">{3}</a></small></td> \n"; - private static final String APPS_ROW_BUTTON_SECTION = + private static final String STARTED_APPS_ROW_BUTTON_SECTION = " <td class=\"row-left\"> \n" + " <small> \n" + - " <a href=\"start?path={0}\">{1}</a> \n" + + " {1} \n" + " <a href=\"stop?path={0}\">{2}</a> \n" + " <a href=\"reload?path={0}\">{3}</a> \n" + " <a href=\"remove?path={0}\">{4}</a> \n" + @@ -510,20 +525,33 @@ " </td> \n" + "</tr> \n"; - private static final String APPS_ROOT_ROW_SECTION = + private static final String STOPPED_APPS_ROW_BUTTON_SECTION = + " <td class=\"row-left\"> \n" + + " <small> \n" + + " <a href=\"start?path={0}\">{1}</a> \n" + + " {2} \n" + + " {3} \n" + + " <a href=\"remove?path={0}\">{4}</a> \n" + + " </small> \n" + + " </td> \n" + + "</tr> \n"; + + private static final String APPS_ROOT_ROW_SECTION = "<tr> \n" + - " <td class=\"row-left\"><small><a href=\"{0}\">{0}</a></small></td> \n" + + " <td class=\"row-left\"><small><a href=\"{0}\">{0}</a></small></td>\n" + " <td class=\"row-left\"><small>{1}</small></td> \n" + " <td class=\"row-center\"><small>{2}</small></td> \n" + " <td class=\"row-center\"><small>{3}</small></td> \n" + " <td class=\"row-right\"> </td> \n" + "</tr> \n"; - private static final String INSTALL_SECTION = + private static final String INSTALL_SECTION = "<tr> \n" + - " <td colspan=\"10\" class=\"header-left\"><small>{0}</small></td> \n" + + " <td colspan=\"10\" class=\"header-left\"><small>{0}</small></td>\n" + "</tr> \n" + "<tr> \n" + + "<form method=\"get\" action=\"install\"> \n" + + "<input type=\"hidden\" name=\"path\"> \n" + " <td colspan=\"10\" class=\"row-left\"> \n" + " <small>{1}</small> \n" + " <input type=\"text\" name=\"installPath\" size=\"10\"> \n" + @@ -533,12 +561,13 @@ " <input type=\"text\" name=\"installWar\" size=\"18\"> \n" + " <input type=\"submit\" value=\"{4}\"> \n" + " </td> \n" + + "</form> \n" + "</tr> \n" + "</table> \n" + "<br> \n" + "\n"; - private static final String SERVER_HEADER_SECTION = + private static final String SERVER_HEADER_SECTION = "<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"> \n" + "<tr> \n" + " <td colspan=\"10\" class=\"title\">{0}</td> \n" + @@ -552,7 +581,7 @@ " <td class=\"header-center\"><small>{6}</small></td> \n" + "</tr> \n"; - private static final String SERVER_ROW_SECTION = + private static final String SERVER_ROW_SECTION = "<tr> \n" + " <td class=\"row-center\"><small>{0}</small></td> \n" + " <td class=\"row-center\"><small>{1}</small></td> \n" + @@ -565,14 +594,7 @@ "<br> \n" + "\n"; - private static final String MESSAGE_SECTION = - "<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"> \n" + - " <tr> \n" + - " <td class=\"row-left\"><small><b>{0}</b> {1}</small></td> \n" + - " </tr> \n" + - "</table> \n" + - "\n" + - "</form> \n" + + private static final String HTML_TAIL_SECTION = "</body> \n" + "</html>"; } 1.18 +10 -10 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings.properties,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- LocalStrings.properties 10 Jun 2002 19:19:23 -0000 1.17 +++ LocalStrings.properties 13 Jun 2002 14:58:01 -0000 1.18 @@ -24,14 +24,14 @@ htmlManagerServlet.serverOSVersion=OS Version htmlManagerServlet.serverTitle=Server htmlManagerServlet.serverVersion=Server Version -htmlManagerServlet.title=Tomcat Manager +htmlManagerServlet.title=Tomcat Web Application Manager invokerServlet.allocate=Cannot allocate servlet instance for path {0} invokerServlet.cannotCreate=Cannot create servlet wrapper for path {0} invokerServlet.deallocate=Cannot deallocate servlet instance for path {0} -invokerServlet.invalidPath=No servlet name or class was specified in path +invokerServlet.invalidPath=No servlet name or class was specified in path {0} invokerServlet.notNamed=Cannot call invoker servlet with a named dispatcher -invokerServlet.noWrapper=Container has not called setWrapper() for this +invokerServlet.noWrapper=Container has not called setWrapper() for this servlet managerServlet.alreadyContext=FAIL - Application already exists at path {0} managerServlet.alreadyDocBase=FAIL - Directory {0} is already in use @@ -44,7 +44,7 @@ managerServlet.invalidWar=FAIL - Invalid application URL {0} was specified managerServlet.listed=OK - Listed applications for virtual host {0} managerServlet.listitem={0}:{1}:{2}:{3} -managerServlet.noAppBase=FAIL - Cannot identify application base for context +managerServlet.noAppBase=FAIL - Cannot identify application base for context path {0} managerServlet.noCommand=FAIL - No command was specified managerServlet.noContext=FAIL - No context exists for path {0} @@ -52,11 +52,11 @@ managerServlet.noDocBase=FAIL - Cannot remove document base for path {0} managerServlet.noGlobal=FAIL - No global JNDI resources are available managerServlet.noPath=FAIL - No context path was specified -managerServlet.noReload=FAIL - Reload not supported on WAR deployed at path +managerServlet.noReload=FAIL - Reload not supported on WAR deployed at path {0} managerServlet.noRename=FAIL - Cannot deploy uploaded WAR for path {0} managerServlet.noRole=FAIL - User does not possess role {0} -managerServlet.noWrapper=Container has not called setWrapper() for this +managerServlet.noWrapper=Container has not called setWrapper() for this servlet managerServlet.reloaded=OK - Reloaded application at context path {0} managerServlet.removed=OK - Removed application at context path {0} @@ -64,18 +64,18 @@ managerServlet.resourcesType=OK - Listed global resources of type {0} managerServlet.rolesList=OK - Listed security roles managerServlet.saveFail=FAIL - Configuration save failed: {0} -managerServlet.sessiondefaultmax=Default maximum session inactive interval +managerServlet.sessiondefaultmax=Default maximum session inactive interval {0} minutes managerServlet.sessiontimeout={0} minutes:{1} sessions -managerServlet.sessions=OK - Session information for application at context +managerServlet.sessions=OK - Session information for application at context path {0} managerServlet.started=OK - Started application at context path {0} -managerServlet.startFailed=FAIL - Application at context path {0} could not +managerServlet.startFailed=FAIL - Application at context path {0} could not be started managerServlet.stopped=OK - Stopped application at context path {0} managerServlet.undeployed=OK - Undeployed application at context path {0} managerServlet.unknownCommand=FAIL - Unknown command {0} -managerServlet.userDatabaseError=FAIL - Cannot resolve user database +managerServlet.userDatabaseError=FAIL - Cannot resolve user database reference managerServlet.userDatabaseMissing=FAIL - No user database is available webdavservlet.jaxpfailed=JAXP initialization failed
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>