Package org.apache.catalina.manager
Class ManagerServlet
- java.lang.Object
- 
- javax.servlet.GenericServlet
- 
- javax.servlet.http.HttpServlet
- 
- org.apache.catalina.manager.ManagerServlet
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- Servlet,- ServletConfig,- ContainerServlet
 - Direct Known Subclasses:
- HTMLManagerServlet
 
 public class ManagerServlet extends HttpServlet implements ContainerServlet 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.This servlet examines the value returned by getPathInfo()and related query parameters to determine what action is being requested. The following actions and parameters (starting after the servlet path) are supported:- /deploy?config={config-url} - Install and start a new
     web application, based on the contents of the context configuration
     file found at the specified URL.  The docBaseattribute of the context configuration file is used to locate the actual WAR or directory containing the application.
- /deploy?config={config-url}&war={war-url}/ - Install and start
     a new web application, based on the contents of the context
     configuration file found at {config-url}, overriding thedocBaseattribute with the contents of the web application archive found at{war-url}.
- /deploy?path=/xxx&war={war-url} - Install and start a new
     web application attached to context path /xxx, based on the contents of the web application archive found at the specified URL.
- /list - List the context paths of all currently installed web
     applications for this virtual host.  Each context will be listed with
     the following format path:status:sessions. Where path is the context path. Status is either running or stopped. Sessions is the number of active Sessions.
- /reload?path=/xxx - Reload the Java classes and resources for the application at the specified path.
- /resources?type=xxxx - Enumerate the available global JNDI resources, optionally limited to those of the specified type (fully qualified Java class name), if available.
- /serverinfo - Display system OS and JVM properties.
- /sessions - Deprecated. Use expire.
- /expire?path=/xxx - List session idle time information about the
     web application attached to context path /xxxfor this virtual host.
- /expire?path=/xxx&idle=mm - Expire sessions
     for the context path /xxxwhich were idle for at least mm minutes.
- /sslConnectorCiphers - Display diagnostic info on SSL/TLS ciphers that are currently configured for each connector.
- /start?path=/xxx - Start the web application attached to
     context path /xxxfor this virtual host.
- /stop?path=/xxx - Stop the web application attached to
     context path /xxxfor this virtual host.
- /threaddump - Write a JVM thread dump.
- /undeploy?path=/xxx - Shutdown and remove the web application
     attached to context path /xxxfor this virtual host, and remove the underlying WAR file or document base directory. (NOTE - This is only allowed if the WAR file or document base is stored in theappBasedirectory of this host, typically as a result of being placed there via the/deploycommand.
- /vminfo - Write some VM info.
- /save - Save the current server configuration to server.xml
- /save?path=/xxx - Save the context configuration for the web
     application deployed with path /xxxto an appropriately named context.xml file in thexmlBasefor the associated Host.
 Use path=/for the ROOT context.The syntax of the URL for a web application archive must conform to one of the following patterns to be successfully deployed: - file:/absolute/path/to/a/directory - You can specify the absolute path of a directory that contains the unpacked version of a web application. This directory will be attached to the context path you specify without any changes.
 NOTE - Attempting to reload or remove the application containing this servlet itself will not succeed. Therefore, this servlet should generally be deployed as a separate web application within the virtual host to be managed. The following servlet initialization parameters are recognized: - debug - The debugging detail level that controls the amount of information that is logged by this servlet. Default is zero.
 - Author:
- Craig R. McClanahan, Remy Maucherat
- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.io.FileconfigBasePath where context descriptors should be deployed.protected ContextcontextThe Context container associated with our web application.protected intdebugThe debugging detail level for this servlet.protected javax.naming.ContextglobalThe global JNDINamingContextfor this server, if available.protected HosthostThe associated host.protected javax.management.MBeanServermBeanServerMBean server.protected javax.management.ObjectNameonameThe associated deployer ObjectName.protected static StringManagersmThe string manager for this package.protected java.io.FileversionedPath used to store revisions of webapps.protected WrapperwrapperThe Wrapper container associated with this servlet.
 - 
Constructor SummaryConstructors Constructor Description ManagerServlet()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddServiced(java.lang.String name)Deprecated.Unused.protected voidcheck(java.lang.String name)Invoke the check method on the deployer.static booleancopy(java.io.File src, java.io.File dest)Copy the specified file or directory to the destination.static booleancopyInternal(java.io.File src, java.io.File dest, byte[] buf)Copy the specified file or directory to the destination.protected voiddeploy(java.io.PrintWriter writer, java.lang.String config, ContextName cn, java.lang.String war, boolean update, StringManager smClient)Install an application for the specified path from the specified web application archive.protected voiddeploy(java.io.PrintWriter writer, ContextName cn, java.lang.String tag, boolean update, HttpServletRequest request, StringManager smClient)Deploy a web application archive (included in the current request) at the specified context path.protected voiddeploy(java.io.PrintWriter writer, ContextName cn, java.lang.String tag, StringManager smClient)Install an application for the specified path from the specified web application archive.voiddestroy()Finalize this servlet.voiddoGet(HttpServletRequest request, HttpServletResponse response)Process a GET request for the specified resource.voiddoPut(HttpServletRequest request, HttpServletResponse response)Process a PUT request for the specified resource.protected voidexpireSessions(java.io.PrintWriter writer, ContextName cn, HttpServletRequest req, StringManager smClient)Extract the expiration request parameterprotected voidfindleaks(boolean statusLine, java.io.PrintWriter writer, StringManager smClient)Find potential memory leaks caused by web application reload.protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>getConnectorCerts(StringManager smClient)protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>getConnectorCiphers(StringManager smClient)protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>getConnectorTrustedCerts(StringManager smClient)WrappergetWrapper()Return the Wrapper with which we are associated.voidinit()Initialize this servlet.protected booleanisDeployed(java.lang.String name)Invoke the isDeployed method on the deployer.protected booleanisServiced(java.lang.String name)Deprecated.Unused.protected voidlist(java.io.PrintWriter writer, StringManager smClient)Render a list of the currently active Contexts in our virtual host.protected voidprintResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, java.lang.Class<?> clazz, StringManager smClient)Deprecated.UseprintResources(PrintWriter, String, javax.naming.Context, String, StringManager)This method will be removed in Tomcat 10.x onwardsprotected voidprintResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, StringManager smClient)List the resources of the given context.protected voidreload(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Reload the web application at the specified context path.protected voidremoveServiced(java.lang.String name)Invoke the removeServiced method on the deployer.protected voidresources(java.io.PrintWriter writer, java.lang.String type, StringManager smClient)Render a list of available global JNDI resources.protected voidsave(java.io.PrintWriter writer, java.lang.String path, StringManager smClient)Store server configuration.protected voidserverinfo(java.io.PrintWriter writer, StringManager smClient)Writes System OS and JVM properties.protected voidsessions(java.io.PrintWriter writer, ContextName cn, int idle, StringManager smClient)Session information for the web application at the specified context path.voidsetWrapper(Wrapper wrapper)Set the Wrapper with which we are associated.protected voidsslConnectorCiphers(java.io.PrintWriter writer, StringManager smClient)protected voidsslReload(java.io.PrintWriter writer, java.lang.String tlsHostName, StringManager smClient)protected voidstart(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Start the web application at the specified context path.protected voidstop(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Stop the web application at the specified context path.protected voidthreadDump(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)Write a JVM thread dump.protected booleantryAddServiced(java.lang.String name)Attempt to mark a context as being servicedprotected voidundeploy(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Undeploy the web application at the specified context path.protected booleanundeployDir(java.io.File dir)Delete the specified directory, including all of its contents and subdirectories recursively.protected voiduploadWar(java.io.PrintWriter writer, HttpServletRequest request, java.io.File war, StringManager smClient)Upload the WAR file included in this request, and store it at the specified file location.protected static booleanvalidateContextName(ContextName cn, java.io.PrintWriter writer, StringManager smClient)protected voidvmInfo(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)Write some VM info.- 
Methods inherited from class javax.servlet.http.HttpServletdoDelete, doHead, doOptions, doPost, doTrace, getLastModified, service, service
 - 
Methods inherited from class javax.servlet.GenericServletgetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
- 
 
- 
- 
- 
Field Detail- 
configBaseprotected java.io.File configBase Path where context descriptors should be deployed.
 - 
contextprotected transient Context context The Context container associated with our web application.
 - 
debugprotected int debug The debugging detail level for this servlet.
 - 
versionedprotected java.io.File versioned Path used to store revisions of webapps.
 - 
hostprotected transient Host host The associated host.
 - 
mBeanServerprotected transient javax.management.MBeanServer mBeanServer MBean server.
 - 
onameprotected javax.management.ObjectName oname The associated deployer ObjectName.
 - 
globalprotected transient javax.naming.Context global The global JNDINamingContextfor this server, if available.
 - 
smprotected static final StringManager sm The string manager for this package.
 - 
wrapperprotected transient Wrapper wrapper The Wrapper container associated with this servlet.
 
- 
 - 
Method Detail- 
getWrapperpublic Wrapper getWrapper() Return the Wrapper with which we are associated.- Specified by:
- getWrapperin interface- ContainerServlet
- Returns:
- The Wrapper with which this Servlet is associated.
 
 - 
setWrapperpublic void setWrapper(Wrapper wrapper) Set the Wrapper with which we are associated.- Specified by:
- setWrapperin interface- ContainerServlet
- Parameters:
- wrapper- The new wrapper
 
 - 
destroypublic void destroy() Finalize this servlet.- Specified by:
- destroyin interface- Servlet
- Overrides:
- destroyin class- GenericServlet
 
 - 
doGetpublic void doGet(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException Process a GET request for the specified resource.- Overrides:
- doGetin class- HttpServlet
- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
- See Also:
- ServletResponse.setContentType(java.lang.String)
 
 - 
doPutpublic void doPut(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException Process a PUT request for the specified resource.- Overrides:
- doPutin class- HttpServlet
- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
 
 - 
initpublic void init() throws ServletExceptionInitialize this servlet.- Overrides:
- initin class- GenericServlet
- Throws:
- ServletException- if an exception occurs that interrupts the servlet's normal operation
 
 - 
findleaksprotected void findleaks(boolean statusLine, java.io.PrintWriter writer, StringManager smClient)Find potential memory leaks caused by web application reload.- Parameters:
- statusLine- Print a status line
- writer- The output writer
- smClient- StringManager for the client's locale
 
 - 
sslReloadprotected void sslReload(java.io.PrintWriter writer, java.lang.String tlsHostName, StringManager smClient)
 - 
vmInfoprotected void vmInfo(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)Write some VM info.- Parameters:
- writer- The output writer
- smClient- StringManager for the client's locale
- requestedLocales- the client's locales
 
 - 
threadDumpprotected void threadDump(java.io.PrintWriter writer, StringManager smClient, java.util.Enumeration<java.util.Locale> requestedLocales)Write a JVM thread dump.- Parameters:
- writer- The output writer
- smClient- StringManager for the client's locale
- requestedLocales- the client's locales
 
 - 
sslConnectorCiphersprotected void sslConnectorCiphers(java.io.PrintWriter writer, StringManager smClient)
 - 
saveprotected void save(java.io.PrintWriter writer, java.lang.String path, StringManager smClient)Store server configuration.- Parameters:
- writer- Destination for any user message(s) during this operation
- path- Optional context path to save
- smClient- i18n support for current client's locale
 
 - 
deployprotected void deploy(java.io.PrintWriter writer, ContextName cn, java.lang.String tag, boolean update, HttpServletRequest request, StringManager smClient)Deploy a web application archive (included in the current request) at the specified context path.- Parameters:
- writer- Writer to render results to
- cn- Name of the application to be installed
- tag- Tag to be associated with the webapp
- update- Flag that indicates that any existing app should be replaced
- request- Servlet request we are processing
- smClient- i18n messages using the locale of the client
 
 - 
deployprotected void deploy(java.io.PrintWriter writer, ContextName cn, java.lang.String tag, StringManager smClient)Install an application for the specified path from the specified web application archive.- Parameters:
- writer- Writer to render results to
- tag- Revision tag to deploy from
- cn- Name of the application to be installed
- smClient- i18n messages using the locale of the client
 
 - 
deployprotected void deploy(java.io.PrintWriter writer, java.lang.String config, ContextName cn, java.lang.String war, boolean update, StringManager smClient)Install an application for the specified path from the specified web application archive.- Parameters:
- writer- Writer to render results to
- config- URL of the context configuration file to be installed
- cn- Name of the application to be installed
- war- URL of the web application archive to be installed
- update- true to override any existing webapp on the path
- smClient- i18n messages using the locale of the client
 
 - 
listprotected void list(java.io.PrintWriter writer, StringManager smClient)Render a list of the currently active Contexts in our virtual host.- Parameters:
- writer- Writer to render to
- smClient- i18n support for current client's locale
 
 - 
reloadprotected void reload(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Reload the web application at the specified context path.- Parameters:
- writer- Writer to render to
- cn- Name of the application to be restarted
- smClient- i18n support for current client's locale
 
 - 
resourcesprotected void resources(java.io.PrintWriter writer, java.lang.String type, StringManager smClient)Render a list of available global JNDI resources.- Parameters:
- writer- Writer to render to
- type- Fully qualified class name of the resource type of interest, or- nullto list resources of all types
- smClient- i18n support for current client's locale
 
 - 
printResources@Deprecated protected void printResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, java.lang.Class<?> clazz, StringManager smClient)Deprecated.UseprintResources(PrintWriter, String, javax.naming.Context, String, StringManager)This method will be removed in Tomcat 10.x onwardsList the resources of the given context.- Parameters:
- writer- Writer to render to
- prefix- Path for recursion
- namingContext- The naming context for lookups
- type- Fully qualified class name of the resource type of interest, or- nullto list resources of all types
- clazz- Unused
- smClient- i18n support for current client's locale
 
 - 
printResourcesprotected void printResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, StringManager smClient)List the resources of the given context.- Parameters:
- writer- Writer to render to
- prefix- Path for recursion
- namingContext- The naming context for lookups
- type- Fully qualified class name of the resource type of interest, or- nullto list resources of all types
- smClient- i18n support for current client's locale
 
 - 
serverinfoprotected void serverinfo(java.io.PrintWriter writer, StringManager smClient)Writes System OS and JVM properties.- Parameters:
- writer- Writer to render to
- smClient- i18n support for current client's locale
 
 - 
sessionsprotected void sessions(java.io.PrintWriter writer, ContextName cn, int idle, StringManager smClient)Session information for the web application at the specified context path. Displays a profile of session thisAccessedTime listing number of sessions for each 10 minute interval up to 10 hours.- Parameters:
- writer- Writer to render to
- cn- Name of the application to list session information for
- idle- Expire all sessions with idle time > idle for this context
- smClient- i18n support for current client's locale
 
 - 
expireSessionsprotected void expireSessions(java.io.PrintWriter writer, ContextName cn, HttpServletRequest req, StringManager smClient)Extract the expiration request parameter- Parameters:
- writer- Writer to render to
- cn- Name of the application to list session information for
- req- The Servlet request
- smClient- i18n support for current client's locale
 
 - 
startprotected void start(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Start the web application at the specified context path.- Parameters:
- writer- Writer to render to
- cn- Name of the application to be started
- smClient- i18n support for current client's locale
 
 - 
stopprotected void stop(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Stop the web application at the specified context path.- Parameters:
- writer- Writer to render to
- cn- Name of the application to be stopped
- smClient- i18n support for current client's locale
 
 - 
undeployprotected void undeploy(java.io.PrintWriter writer, ContextName cn, StringManager smClient)Undeploy the web application at the specified context path.- Parameters:
- writer- Writer to render to
- cn- Name of the application to be removed
- smClient- i18n support for current client's locale
 
 - 
isDeployedprotected boolean isDeployed(java.lang.String name) throws java.lang.ExceptionInvoke the isDeployed method on the deployer.- Parameters:
- name- The webapp name
- Returns:
- trueif a webapp with that name is deployed
- Throws:
- java.lang.Exception- Propagate JMX invocation error
 
 - 
checkprotected void check(java.lang.String name) throws java.lang.ExceptionInvoke the check method on the deployer.- Parameters:
- name- The webapp name
- Throws:
- java.lang.Exception- Propagate JMX invocation error
 
 - 
isServiced@Deprecated protected boolean isServiced(java.lang.String name) throws java.lang.ExceptionDeprecated.Unused. Will be removed in Tomcat 10.1.x onwards.Invoke the isServiced method on the deployer.- Parameters:
- name- The webapp name
- Returns:
- trueif a webapp with that name is being serviced
- Throws:
- java.lang.Exception- Propagate JMX invocation error
 
 - 
addServiced@Deprecated protected void addServiced(java.lang.String name) throws java.lang.ExceptionDeprecated.Unused. Will be removed in Tomcat 10.1.x onwards. UsetryAddServiced(java.lang.String)Invoke the addServiced method on the deployer.- Parameters:
- name- The webapp name
- Throws:
- java.lang.Exception- Propagate JMX invocation error
 
 - 
tryAddServicedprotected boolean tryAddServiced(java.lang.String name) throws java.lang.ExceptionAttempt to mark a context as being serviced- Parameters:
- name- The context name
- Returns:
- trueif the application was marked as being serviced and- falseif the application was already marked as being serviced
- Throws:
- java.lang.Exception- Error invoking the deployer
 
 - 
removeServicedprotected void removeServiced(java.lang.String name) throws java.lang.ExceptionInvoke the removeServiced method on the deployer.- Parameters:
- name- The webapp name
- Throws:
- java.lang.Exception- Propagate JMX invocation error
 
 - 
undeployDirprotected boolean undeployDir(java.io.File dir) Delete the specified directory, including all of its contents and subdirectories recursively. The code assumes that the directory exists.- Parameters:
- dir- File object representing the directory to be deleted.
- Returns:
- trueif the deletion was successful
 
 - 
uploadWarprotected void uploadWar(java.io.PrintWriter writer, HttpServletRequest request, java.io.File war, StringManager smClient) throws java.io.IOExceptionUpload the WAR file included in this request, and store it at the specified file location.- Parameters:
- writer- Writer to render to
- request- The servlet request we are processing
- war- The file into which we should store the uploaded WAR
- smClient- The StringManager used to construct i18n messages based on the Locale of the client
- Throws:
- java.io.IOException- if an I/O error occurs during processing
 
 - 
validateContextNameprotected static boolean validateContextName(ContextName cn, java.io.PrintWriter writer, StringManager smClient) 
 - 
copypublic static boolean copy(java.io.File src, java.io.File dest)Copy the specified file or directory to the destination.- Parameters:
- src- File object representing the source
- dest- File object representing the destination
- Returns:
- trueif the copy was successful
 
 - 
copyInternalpublic static boolean copyInternal(java.io.File src, java.io.File dest, byte[] buf)Copy the specified file or directory to the destination.- Parameters:
- src- File object representing the source
- dest- File object representing the destination
- buf- Temp byte buffer
- Returns:
- trueif the copy was successful
 
 - 
getConnectorCiphersprotected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConnectorCiphers(StringManager smClient) 
 - 
getConnectorCertsprotected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConnectorCerts(StringManager smClient) 
 - 
getConnectorTrustedCertsprotected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getConnectorTrustedCerts(StringManager smClient) 
 
- 
 
-