Re: [PATCH] improved HTMLManagerServlet
sting. * * The difference between this ManagerServlet and this * Servlet is that this Servlet prints out a HTML interface which * makes it easier to administrate. * * However if you use a software that parses the output of * ManagerServletManagerServlet * * @author Bip Thelin * @author Malcolm Edgar * @version $Revision: 1.7 $, $Date: 2002/06/10 19:19:23 $ * @see ManagerServlet */ public final class HTMLManagerServlet extends ManagerServlet { // - Public Methods /** * Process a GET request for the specified resource. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet-specified error occurs */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Identify the request parameters that we need String command = request.getPathInfo(); String path = request.getParameter("path"); String installPath = request.getParameter("installPath"); String installConfig = request.getParameter("installConfig"); String installWar = request.getParameter("installWar"); // Prepare our output writer to generate the response message response.setContentType("text/html"); PrintWriter writer = response.getWriter(); // Process the requested command if (command == null) { response.sendRedirect(request.getRequestURI()+"/list"); } else if (command.equals("/install")) { install(writer, installConfig, installPath, installWar); } else if (command.equals("/list")) { list(writer, ""); } else if (command.equals("/reload")) { reload(writer, path); } else if (command.equals("/remove")) { remove(writer, path); } else if (command.equals("/sessions")) { sessions(writer, path); } else if (command.equals("/start")) { start(writer, path); } else if (command.equals("/stop")) { stop(writer, path); } else { String message = sm.getString("managerServlet.unknownCommand", command); list(writer, message); } // Finish up the response writer.flush(); writer.close(); } /** * Install an application for the specified path from the specified * web application archive. * * @param writer Writer to render results to * @param config URL of the context configuration file to be installed * @param path Context path of the application to be installed * @param war URL of the web application archive to be installed */ protected void install(PrintWriter writer, String config, String path, String war) { 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, * and memory and server status information. * * @param writer Writer to render to * @param message a message to display */ public void list(PrintWriter writer, String message) { if (debug >= 1) log("list: Listing contexts for virtual host '" + deployer.getName() + "'"); // HTML Header Section writer.print(HTML_HEADER_SECTION); // Body Header Section 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"); writer.print(MessageFormat.format(APPS_HEADER_SECTION, args)); // Apps Row Section // Create s
Re: [PATCH] improved HTMLManagerServlet
Glenn Nielsen wrote: >I have a number of comments. First thanks for working on improving the >HTMLManagerServlet. > >1. GC should not be user initiated, it should be left to the JVM. > In addition, when virtual hosting web sites, those who have permission > to manage applications for a particluar host may not be the > system admin for Tomcat. I wouldn't want them to be able to trigger a >GC. > The GC option needs to be removed. Done >2. The js which you added for onClick really isn't necessary. The > HTMLManagerServlet should be usable w/o JavaScript enabled > in the browser. It should be removed. Done >3. The listing of memory usage isn't really needed if GC is removed. > It doesn't provide info that is of benefit to someone > who just manages web applications and is not the Tomcat sysad. > A Tomcat sysad would be better off using the -verbose:gc arg to > java when starting Tomcat so that they collect GC data which they > can later graph to profile the Tomcat JVM memory usage. Done The memory status stuff is probably out of place here. A performance monitoring module could be included in the Admin application, covering mem status, request response time, etc. Regards Malcolm Edgar _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. defaultservlet.directorylistingfor=Directory Listing for: defaultservlet.upto=Up to: defaultservlet.subdirectories=Subdirectories: defaultservlet.files=Files: htmlManagerServlet.appsAvailable=Running htmlManagerServlet.appsName=Display Name htmlManagerServlet.appsPath=Path htmlManagerServlet.appsReload=Reload htmlManagerServlet.appsRemove=Remove htmlManagerServlet.appsSessions=Sessions htmlManagerServlet.appsStart=Start htmlManagerServlet.appsStop=Stop htmlManagerServlet.appsTitle=Applications htmlManagerServlet.installButton=Install htmlManagerServlet.installConfig=Config URL: htmlManagerServlet.installPath=Path: htmlManagerServlet.installTitle=Install htmlManagerServlet.installWar=WAR URL: htmlManagerServlet.messageLabel=Message: htmlManagerServlet.serverJVMVendor=JVM Vendor htmlManagerServlet.serverJVMVersion=JVM Version htmlManagerServlet.serverOSArch=OS Arch htmlManagerServlet.serverOSName=OS Name htmlManagerServlet.serverOSVersion=OS Version htmlManagerServlet.serverTitle=Server htmlManagerServlet.serverVersion=Server Version htmlManagerServlet.title=Tomcat 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 {0} invokerServlet.notNamed=Cannot call invoker servlet with a named dispatcher 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 managerServlet.cannotInvoke=Cannot invoke manager servlet through invoker managerServlet.configured=OK - Installed application from context file {0} managerServlet.deployed=OK - Deployed application at context path {0} managerServlet.exception=FAIL - Encountered exception {0} managerServlet.installed=OK - Installed application at context path {0} managerServlet.invalidPath=FAIL - Invalid context path {0} was specified 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 path {0} managerServlet.noCommand=FAIL - No command was specified managerServlet.noContext=FAIL - No context exists for path {0} managerServlet.noDirectory=FAIL - Non-directory document base for path {0} 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 {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 servlet managerServlet.reloaded=OK - Reloaded application at context path {0} managerServlet.removed=OK - Removed application at context path {0} managerServlet.resourcesAll=OK - Listed global resources of all types 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 sessio
Re: [PATCH] improved HTMLManagerServlet
Glenn Nielsen wrote: >list.html wasn't attached. Please cut & paste the HTML below. Their is a virus on this PC jumping on the list.html file stopping it from being sent. Regards Malcolm Edgar table { width: 100%; } td.page-title { text-align: center; vertical-align: top; font-family:verdana,sans-serif; font-weight: bold; background: white; color: black; } td.title { text-align: left; vertical-align: top; font-family:verdana,sans-serif; font-style:italic; font-weight: bold; background: #D2A41C; } td.header-left { text-align: left; vertical-align: top; font-family:verdana,sans-serif; font-weight: bold; background: #FFDC75; } td.header-center { text-align: center; vertical-align: top; font-family:verdana,sans-serif; font-weight: bold; background: #FFDC75; } td.row-left { text-align: left; vertical-align: middle; font-family:verdana,sans-serif; color: black; background: white; } td.row-center { text-align: center; vertical-align: middle; font-family:verdana,sans-serif; color: black; background: white; } td.row-right { text-align: right; vertical-align: middle; font-family:verdana,sans-serif; color: black; background: white; } Tomcat Manager Tomcat Manager Applications Path Display Name Running Sessions / ROOT true - /admin false 0 /examples true 0 /manager true 0 /tomcat-docs true 0 /webdav true 0 Install Path: Config URL: WAR URL: Memory Status Total Availabe Percentage Used Time 9,164 KB 3,799 KB 58 % 5/24/02 11:31 AM Server Server Version JVM Version JVM Vendor OS Name OS Version OS Arch Apache Tomcat/4.1.1 1.3.1_03-b03 Sun Microsystems Inc. Windows 2000 5.0 x86 Message: _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: [PATCH] improved HTMLManagerServlet
Glenn Nielsen wrote: >I have a number of comments. First thanks for working on improving the >HTMLManagerServlet. > >1. GC should not be user initiated, it should be left to the JVM. > In addition, when virtual hosting web sites, those who have permission > to manage applications for a particluar host may not be the > system admin for Tomcat. I wouldn't want them to be able to trigger a >GC. > The GC option needs to be removed. I agree the GC should not generally be run by users, however the access to the manager app should limited to admins and developers, so I dont believe this would be an problem. I had the experience of developing/profiling Tomcat apps located in the US while working in Australia for Avaya. To do this we developed a performance monitoring app, doing this sort of thing which was extremely useful. >2. The js which you added for onClick really isn't necessary. The > HTMLManagerServlet should be usable w/o JavaScript enabled > in the browser. It should be removed. How would you do this in a POST request? I could use GET request but params url string is exposed, though I suppose this doesn't really matter for this application. >3. The listing of memory usage isn't really needed if GC is removed. > It doesn't provide info that is of benefit to someone > who just manages web applications and is not the Tomcat sysad. > A Tomcat sysad would be better off using the -verbose:gc arg to > java when starting Tomcat so that they collect GC data which they > can later graph to profile the Tomcat JVM memory usage. > I think it is handy to have a non-intrusive (although limited) way of examining memory status of servers in production or undergoing UAT. That said I am not married to it, so I can remove it if required. >These comments are just from a quick review of the code, I haven't >compiled it and tried it out. > > >list.html wasn't attached. Please see attached file, not sure what happend the first time. Thanks for the feed back. Regards Malcolm Edgar _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
[PATCH] improved HTMLManagerServlet
Hi all, Please see the proposed patch for HTMLManagerServlet. This provides an improved UI, memory and server reporting information, gc command, supports 4.1 manager install command and internationalization. This is almost a rewrite of HTMLManagerServlet, so the diff is not particularly informative. Please see the attached files: * list.html - example HTML output of list command * HTMLManagerServlet.java - source code * LocalStrings.properties - localization strings Regards Malcolm Edgar _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com HTMLManagerServlet.java Description: JavaScript source defaultservlet.directorylistingfor=Directory Listing for: defaultservlet.upto=Up to: defaultservlet.subdirectories=Subdirectories: defaultservlet.files=Files: htmlManagerServlet.appsTitle=Applications htmlManagerServlet.appsPath=Path htmlManagerServlet.appsName=Display Name htmlManagerServlet.appsAvailable=Running htmlManagerServlet.appsSessions=Sessions htmlManagerServlet.appsStart=Start htmlManagerServlet.appsStop=Stop htmlManagerServlet.appsReload=Reload htmlManagerServlet.appsRemove=Remove htmlManagerServlet.installTitle=Install htmlManagerServlet.installPath=Path: htmlManagerServlet.installConfig=Config URL: htmlManagerServlet.installWar=WAR URL: htmlManagerServlet.installButton=Install htmlManagerServlet.memoryTitle=Memory Status htmlManagerServlet.memoryTotal=Total htmlManagerServlet.memoryAvailable=Availabe htmlManagerServlet.memoryUsed=Percentage Used htmlManagerServlet.memoryTime=Time htmlManagerServlet.memoryRefresh=Refresh htmlManagerServlet.memoryRunGC=Run GC htmlManagerServlet.messageLabel=Message: htmlManagerServlet.serverTitle=Server htmlManagerServlet.serverVersion=Server Version htmlManagerServlet.serverJVMVersion=JVM Version htmlManagerServlet.serverJVMVendor=JVM Vendor htmlManagerServlet.serverOSName=OS Name htmlManagerServlet.serverOSVersion=OS Version htmlManagerServlet.serverOSArch=OS Arch htmlManagerServlet.title=Tomcat 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 {0} invokerServlet.notNamed=Cannot call invoker servlet with a named dispatcher 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 managerServlet.cannotInvoke=Cannot invoke manager servlet through invoker managerServlet.configured=OK - Installed application from context file {0} managerServlet.deployed=OK - Deployed application at context path {0} managerServlet.exception=FAIL - Encountered exception {0} managerServlet.installed=OK - Installed application at context path {0} managerServlet.invalidPath=FAIL - Invalid context path {0} was specified 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 path {0} managerServlet.noCommand=FAIL - No command was specified managerServlet.noContext=FAIL - No context exists for path {0} managerServlet.noDirectory=FAIL - Non-directory document base for path {0} 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 {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 servlet managerServlet.reloaded=OK - Reloaded application at context path {0} managerServlet.removed=OK - Removed application at context path {0} managerServlet.resourcesAll=OK - Listed global resources of all types 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 {0} minutes managerServlet.sessiontimeout={0} minutes:{1} sessions 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 be started managerServlet.stopped=OK - Stopped application at context path {0} managerServlet.undeployed=OK - Undeployed application at context path {0
Added Oracle JDBC DataSource Example
Hi, I have added an "Oracle JDBC DataSource Example" to the "JDBC Data Sources" section of jndi-resources-howto.xml (from jakarta-tomcat-4.0-src-20020514 build). I don't know what the policy is for doco on non-open source stuff, but if you want to include it that would be great. regards Malcolm Edgar _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx ]> &project; Craig R. McClanahan JNDI Resources HOW-TO Tomcat 4 provides a JNDI InitialContext implementation instance to web applications running under it, in a manner that is compatible with those provided by a http://java.sun.com/j2ee";>Java2 Enterprise Edition application server. Entries in this InitialContext are configured in the $CATALINA_HOME/conf/server.xml file, and may be referenced by the following elements in the web application deployment descriptor (/WEB-INF/web.xml) of your web application: <env-entry> - Environment entry, a single-value parameter that can be used to configure how the application will operate. <resource-ref> - Resource reference, which is typically to an object factory for resources such as a JDBC DataSource, a JavaMail Session, or custom object factories configured into Tomcat 4. <resource-env-ref> - Resource environment reference, a new variation of resource-ref added in Servlet 2.3 that is simpler to configure for resources that do not require authentication information. The InitialContext is configured as a web application is initially deployed, and is made available to web application components (for read-only access). All configured entries and resources will be placed in the java:comp/env portion of the JNDI namespace, so a typical access to a resource - in this case, to a JDBC DataSource - would look something like this: // Obtain our environment naming context Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); // Look up our data source DataSource ds = (DataSource) envCtx.lookup("jdbc/EmployeeDB"); // Allocate and use a connection from the pool Connection conn = ds.getConnection(); ... use this connection to access the database ... conn.close(); See the following Specifications for more information about programming APIs for JNDI, and for the features supported by Java2 Enterprise Edition (J2EE) servers, which Tomcat emulates for the services that it provides: http://java.sun.com/products/jndi/#download";>Java Naming and Directory Interface (included in JDK 1.4, available separately for prior JDK versions) http://java.sun.com/j2ee/download.html";>J2EE Platform Specification (in particular, see Chapter 5 on Naming) Each available JNDI Resource is configured based on inclusion of the following elements in the $CATALINA_HOME/conf/server.xml file: <Environment> - Configure names and values for scalar environment entries that will be exposed to the web application through the JNDI InitialContext (equivalent to the inclusion of an <env-entry> element in the web application deployment descriptor). <Resource> - Configure the name and data type of a resource made available to the application (equivalent to the inclusion of a <resource-ref> element in the web application deployment descriptor). <ResourceParams> - Configure the Java class name of the resource factory implementation to be used, as well as JavaBeans properties used to configure that resource factory. <ResourceLink> - Add a link to a resource defined in the global JNDI context. Any number of these elements may be nested inside a <Context> element (to be associated only with that particular web application) or inside a <DefaultContext> element (used to set the default configuration characteristics for automatically deloyed applications). In addition, the names and values of all <env-entry> elements included in the web application deployment descriptor (/WEB-INF/web.xml) are configured into the initial context as well, overriding corresponding values from conf/server.xml only if allowed by the corresponding <Environment> element (by setting the override attribute to "true"). Global resources can be defined in the server-wide JNDI context, by adding the resource elements described above to the <GlobalNamingResources> child element of the <Server> element. Tomcat 4 includes a series of standard resource factories that can provide services to your web applications, but give you configuration flexibility (in $CATALINA_HOME/conf/server.xml) without modifying the web application or the deployment descriptor. Each subsection below details the