Top Description Fields Constructors Methods
org.apache.catalina.manager

public Class ManagerServlet

extends HttpServlet
implements ContainerServlet
Class Inheritance
All Implemented Interfaces
org.apache.catalina.ContainerServlet
Known Direct Subclasses
org.apache.catalina.manager.HTMLManagerServlet
Imports
java.io.File, .FileOutputStream, .IOException, .OutputStream, .PrintWriter, java.security.cert.Certificate, .X509Certificate, java.util.ArrayList, .Arrays, .Enumeration, .HashMap, .LinkedHashSet, .List, .Locale, .Map, .Set, javax.management.MBeanServer, .MalformedObjectNameException, .ObjectName, javax.naming.Binding, .NamingEnumeration, jakarta.servlet.ServletContext, .ServletException, .ServletInputStream, .UnavailableException, jakarta.servlet.http.HttpServlet, .HttpServletRequest, .HttpServletResponse, org.apache.catalina.Container, .ContainerServlet, .Context, .Engine, .Host, .Manager, .Server, .Service, .Session, .Wrapper, org.apache.catalina.connector.Connector, org.apache.catalina.core.StandardHost, org.apache.catalina.startup.ExpandWar, org.apache.catalina.util.ContextName, .IOTools, .ServerInfo, org.apache.coyote.ProtocolHandler, org.apache.coyote.http11.AbstractHttp11Protocol, org.apache.tomcat.util.Diagnostics, .ExceptionUtils, .IntrospectionUtils, org.apache.tomcat.util.buf.StringUtils, org.apache.tomcat.util.modeler.Registry, org.apache.tomcat.util.net.SSLContext, .SSLHostConfig, .SSLHostConfigCertificate, .SSLUtilBase, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.security.Escape

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:

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:

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:

Authors
Craig R. McClanahan, Remy Maucherat

Field Summary

Modifier and TypeField and Description
protected File
configBase

Path where context descriptors should be deployed.

protected transient Context
context

The Context container associated with our web application.

protected int
debug

The debugging detail level for this servlet.

protected transient Context
global

The global JNDI NamingContext for this server, if available.

protected transient Host
host

The associated host.

protected transient MBeanServer
mBeanServer

MBean server.

protected ObjectName
oname

The associated deployer ObjectName.

private static final long
protected static final StringManager
sm

The string manager for this package.

protected File
versioned

Path used to store revisions of webapps.

protected transient Wrapper
wrapper

The Wrapper container associated with this servlet.

Inherited from jakarta.servlet.http.HttpServlet:
LEGACY_DO_HEAD

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
check(String
The webapp name
name
)

Invoke the check method on the deployer.

protected void
deploy(PrintWriter
Writer to render results to
writer
,
String
URL of the context configuration file to be installed
config
,
ContextName
Name of the application to be installed
cn
,
String
Tag to be associated with the webapp
tag
,
boolean
Flag that indicates that any existing app should be replaced
update
,
HttpServletRequest
Servlet request we are processing
request
,
StringManager
i18n messages using the locale of the client
smClient
)

Deploy a web application archive (included in the current request) at the specified context path.

protected void
deploy(PrintWriter
Writer to render results to
writer
,
ContextName
Name of the application to be installed
cn
,
String
Revision tag to deploy from
tag
,
StringManager
i18n messages using the locale of the client
smClient
)

Install an application for the specified path from the specified web application archive.

protected void
deploy(PrintWriter
Writer to render results to
writer
,
String
URL of the context configuration file to be installed
config
,
ContextName
Name of the application to be installed
cn
,
String
URL of the web application archive to be installed
war
,
boolean
true to override any existing webapp on the path
update
,
StringManager
i18n messages using the locale of the client
smClient
)

Install an application for the specified path from the specified web application archive.

public void
public void
doGet(HttpServletRequest
The servlet request we are processing
request
,
HttpServletResponse
The servlet response we are creating
response
)

Overrides jakarta.servlet.http.HttpServlet.doGet.

Process a GET request for the specified resource.

public void
doPut(HttpServletRequest
The servlet request we are processing
request
,
HttpServletResponse
The servlet response we are creating
response
)

Overrides jakarta.servlet.http.HttpServlet.doPut.

Process a PUT request for the specified resource.

protected void
expireSessions(PrintWriter
Writer to render to
writer
,
ContextName
Name of the application to list session information for
cn
,
HttpServletRequest
The Servlet request
req
,
StringManager
i18n support for current client's locale
smClient
)

Extract the expiration request parameter

protected void
findleaks(boolean
Print a status line
statusLine
,
PrintWriter
The output writer
writer
,
StringManager
StringManager for the client's locale
smClient
)

Find potential memory leaks caused by web application reload.

protected Map<String, List<String>>
protected Map<String, List<String>>
private Connector[]
protected Map<String, List<String>>
public Wrapper
getWrapper()

Implements org.apache.catalina.ContainerServlet.getWrapper.

Return the Wrapper with which we are associated.

public void
init()

Overrides jakarta.servlet.GenericServlet.init.

Initialize this servlet.

protected boolean

Returns:

true if a webapp with that name is deployed
isDeployed
(String
The webapp name
name
)

Invoke the isDeployed method on the deployer.

protected void
list(PrintWriter
Writer to render to
writer
,
StringManager
i18n support for current client's locale
smClient
)

Render a list of the currently active Contexts in our virtual host.

protected void
printResources(PrintWriter
Writer to render to
writer
,
String
Path for recursion
prefix
,
Context
The naming context for lookups
namingContext
,
String
Fully qualified class name of the resource type of interest, or null to list resources of all types
type
,
StringManager
i18n support for current client's locale
smClient
)

List the resources of the given context.

protected void
reload(PrintWriter
Writer to render to
writer
,
ContextName
Name of the application to be restarted
cn
,
StringManager
i18n support for current client's locale
smClient
)

Reload the web application at the specified context path.

protected void
removeServiced(String
The webapp name
name
)

Invoke the removeServiced method on the deployer.

protected void
resources(PrintWriter
Writer to render to
writer
,
String
Fully qualified class name of the resource type of interest, or null to list resources of all types
type
,
StringManager
i18n support for current client's locale
smClient
)

Render a list of available global JNDI resources.

protected synchronized void
save(PrintWriter
Destination for any user message(s) during this operation
writer
,
String
Optional context path to save
path
,
StringManager
i18n support for current client's locale
smClient
)

Store server configuration.

protected void
serverinfo(PrintWriter
Writer to render to
writer
,
StringManager
i18n support for current client's locale
smClient
)

Writes System OS and JVM properties.

protected void
sessions(PrintWriter
Writer to render to
writer
,
ContextName
Name of the application to list session information for
cn
,
int
Expire all sessions with idle time > idle for this context
idle
,
StringManager
i18n support for current client's locale
smClient
)

Session information for the web application at the specified context path.

public void
setWrapper(Wrapper
The new wrapper
wrapper
)

Implements org.apache.catalina.ContainerServlet.setWrapper.

Set the Wrapper with which we are associated.

private void
protected void
private void
protected void
sslReload(PrintWriter writer, String tlsHostName, StringManager smClient)

protected void
start(PrintWriter
Writer to render to
writer
,
ContextName
Name of the application to be started
cn
,
StringManager
i18n support for current client's locale
smClient
)

Start the web application at the specified context path.

protected void
stop(PrintWriter
Writer to render to
writer
,
ContextName
Name of the application to be stopped
cn
,
StringManager
i18n support for current client's locale
smClient
)

Stop the web application at the specified context path.

protected void
threadDump(PrintWriter
The output writer
writer
,
StringManager
StringManager for the client's locale
smClient
,
Enumeration<Locale>
the client's locales
requestedLocales
)

Write a JVM thread dump.

protected boolean

Returns:

true if the application was marked as being serviced and false if the application was already marked as being serviced
tryAddServiced
(String
The context name
name
)

Attempt to mark a context as being serviced

protected void
undeploy(PrintWriter
Writer to render to
writer
,
ContextName
Name of the application to be removed
cn
,
StringManager
i18n support for current client's locale
smClient
)

Undeploy the web application at the specified context path.

protected void
uploadWar(PrintWriter
Writer to render to
writer
,
HttpServletRequest
The servlet request we are processing
request
,
File
The file into which we should store the uploaded WAR
war
,
StringManager
The StringManager used to construct i18n messages based on the Locale of the client
smClient
)

Upload the WAR file included in this request, and store it at the specified file location.

protected static boolean
protected void
vmInfo(PrintWriter
The output writer
writer
,
StringManager
StringManager for the client's locale
smClient
,
Enumeration<Locale>
the client's locales
requestedLocales
)

Write some VM info.

private void
writeDeployResult(PrintWriter writer, StringManager smClient, String name, String displayPath)

Inherited from jakarta.servlet.http.HttpServlet:
doDeletedoHeaddoOptionsdoPostdoTracegetLastModifiedinitserviceservice

Field Detail

configBaseback to summary
protected File configBase

Path where context descriptors should be deployed.

contextback to summary
protected transient Context context

The Context container associated with our web application.

debugback to summary
protected int debug

The debugging detail level for this servlet.

globalback to summary
protected transient Context global

The global JNDI NamingContext for this server, if available.

hostback to summary
protected transient Host host

The associated host.

mBeanServerback to summary
protected transient MBeanServer mBeanServer

MBean server.

onameback to summary
protected ObjectName oname

The associated deployer ObjectName.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides jakarta.servlet.http.HttpServlet.serialVersionUID.

smback to summary
protected static final StringManager sm

The string manager for this package.

versionedback to summary
protected File versioned

Path used to store revisions of webapps.

wrapperback to summary
protected transient Wrapper wrapper

The Wrapper container associated with this servlet.

Constructor Detail

ManagerServletback to summary
public ManagerServlet()

Method Detail

checkback to summary
protected void check(String name) throws Exception

Invoke the check method on the deployer.

Parameters
name:String

The webapp name

Exceptions
Exception:
Propagate JMX invocation error
deployback to summary
protected void deploy(PrintWriter writer, String config, ContextName cn, 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:PrintWriter

Writer to render results to

config:String

URL of the context configuration file to be installed

cn:ContextName

Name of the application to be installed

tag:String

Tag to be associated with the webapp

update:boolean

Flag that indicates that any existing app should be replaced

request:HttpServletRequest

Servlet request we are processing

smClient:StringManager

i18n messages using the locale of the client

deployback to summary
protected void deploy(PrintWriter writer, ContextName cn, String tag, StringManager smClient)

Install an application for the specified path from the specified web application archive.

Parameters
writer:PrintWriter

Writer to render results to

cn:ContextName

Name of the application to be installed

tag:String

Revision tag to deploy from

smClient:StringManager

i18n messages using the locale of the client

deployback to summary
protected void deploy(PrintWriter writer, String config, ContextName cn, String war, boolean update, StringManager smClient)

Install an application for the specified path from the specified web application archive.

Parameters
writer:PrintWriter

Writer to render results to

config:String

URL of the context configuration file to be installed

cn:ContextName

Name of the application to be installed

war:String

URL of the web application archive to be installed

update:boolean

true to override any existing webapp on the path

smClient:StringManager

i18n messages using the locale of the client

destroyback to summary
public void destroy()

Overrides jakarta.servlet.GenericServlet.destroy.

Implements jakarta.servlet.Servlet.destroy.

Finalize this servlet.

Annotations
@Override
doGetback to summary
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

Overrides jakarta.servlet.http.HttpServlet.doGet.

Process a GET request for the specified resource.

Parameters
request:HttpServletRequest

The servlet request we are processing

response:HttpServletResponse

The servlet response we are creating

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
ServletException:
if a servlet-specified error occurs
doPutback to summary
public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

Overrides jakarta.servlet.http.HttpServlet.doPut.

Process a PUT request for the specified resource.

Parameters
request:HttpServletRequest

The servlet request we are processing

response:HttpServletResponse

The servlet response we are creating

Annotations
@Override
Exceptions
IOException:
if an input/output error occurs
ServletException:
if a servlet-specified error occurs
expireSessionsback to summary
protected void expireSessions(PrintWriter writer, ContextName cn, HttpServletRequest req, StringManager smClient)

Extract the expiration request parameter

Parameters
writer:PrintWriter

Writer to render to

cn:ContextName

Name of the application to list session information for

req:HttpServletRequest

The Servlet request

smClient:StringManager

i18n support for current client's locale

findleaksback to summary
protected void findleaks(boolean statusLine, PrintWriter writer, StringManager smClient)

Find potential memory leaks caused by web application reload.

Parameters
statusLine:boolean

Print a status line

writer:PrintWriter

The output writer

smClient:StringManager

StringManager for the client's locale

getConnectorCertsback to summary
protected Map<String, List<String>> getConnectorCerts(StringManager smClient)
getConnectorCiphersback to summary
protected Map<String, List<String>> getConnectorCiphers(StringManager smClient)
getConnectorsback to summary
private Connector[] getConnectors()
getConnectorTrustedCertsback to summary
protected Map<String, List<String>> getConnectorTrustedCerts(StringManager smClient)
getWrapperback to summary
public Wrapper getWrapper()

Implements org.apache.catalina.ContainerServlet.getWrapper.

Return the Wrapper with which we are associated.

Returns:Wrapper

Doc from org.apache.catalina.ContainerServlet.getWrapper.

The Wrapper with which this Servlet is associated.

Annotations
@Override
initback to summary
public void init() throws ServletException

Overrides jakarta.servlet.GenericServlet.init.

Initialize this servlet.

Annotations
@Override
Exceptions
ServletException:

Doc from jakarta.servlet.GenericServlet.init.

if an exception occurs that interrupts the servlet's normal operation

isDeployedback to summary
protected boolean isDeployed(String name) throws Exception

Invoke the isDeployed method on the deployer.

Parameters
name:String

The webapp name

Returns:boolean

true if a webapp with that name is deployed

Exceptions
Exception:
Propagate JMX invocation error
listback to summary
protected void list(PrintWriter writer, StringManager smClient)

Render a list of the currently active Contexts in our virtual host.

Parameters
writer:PrintWriter

Writer to render to

smClient:StringManager

i18n support for current client's locale

printResourcesback to summary
protected void printResources(PrintWriter writer, String prefix, Context namingContext, String type, StringManager smClient)

List the resources of the given context.

Parameters
writer:PrintWriter

Writer to render to

prefix:String

Path for recursion

namingContext:Context

The naming context for lookups

type:String

Fully qualified class name of the resource type of interest, or null to list resources of all types

smClient:StringManager

i18n support for current client's locale

reloadback to summary
protected void reload(PrintWriter writer, ContextName cn, StringManager smClient)

Reload the web application at the specified context path.

Parameters
writer:PrintWriter

Writer to render to

cn:ContextName

Name of the application to be restarted

smClient:StringManager

i18n support for current client's locale

removeServicedback to summary
protected void removeServiced(String name) throws Exception

Invoke the removeServiced method on the deployer.

Parameters
name:String

The webapp name

Exceptions
Exception:
Propagate JMX invocation error
resourcesback to summary
protected void resources(PrintWriter writer, String type, StringManager smClient)

Render a list of available global JNDI resources.

Parameters
writer:PrintWriter

Writer to render to

type:String

Fully qualified class name of the resource type of interest, or null to list resources of all types

smClient:StringManager

i18n support for current client's locale

saveback to summary
protected synchronized void save(PrintWriter writer, String path, StringManager smClient)

Store server configuration.

Parameters
writer:PrintWriter

Destination for any user message(s) during this operation

path:String

Optional context path to save

smClient:StringManager

i18n support for current client's locale

serverinfoback to summary
protected void serverinfo(PrintWriter writer, StringManager smClient)

Writes System OS and JVM properties.

Parameters
writer:PrintWriter

Writer to render to

smClient:StringManager

i18n support for current client's locale

sessionsback to summary
protected void sessions(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:PrintWriter

Writer to render to

cn:ContextName

Name of the application to list session information for

idle:int

Expire all sessions with idle time > idle for this context

smClient:StringManager

i18n support for current client's locale

setWrapperback to summary
public void setWrapper(Wrapper wrapper)

Implements org.apache.catalina.ContainerServlet.setWrapper.

Set the Wrapper with which we are associated.

Parameters
wrapper:Wrapper

The new wrapper

Annotations
@Override
sslConnectorCertsback to summary
private void sslConnectorCerts(PrintWriter writer, StringManager smClient)
sslConnectorCiphersback to summary
protected void sslConnectorCiphers(PrintWriter writer, StringManager smClient)
sslConnectorTrustedCertsback to summary
private void sslConnectorTrustedCerts(PrintWriter writer, StringManager smClient)
sslReloadback to summary
protected void sslReload(PrintWriter writer, String tlsHostName, StringManager smClient)
startback to summary
protected void start(PrintWriter writer, ContextName cn, StringManager smClient)

Start the web application at the specified context path.

Parameters
writer:PrintWriter

Writer to render to

cn:ContextName

Name of the application to be started

smClient:StringManager

i18n support for current client's locale

stopback to summary
protected void stop(PrintWriter writer, ContextName cn, StringManager smClient)

Stop the web application at the specified context path.

Parameters
writer:PrintWriter

Writer to render to

cn:ContextName

Name of the application to be stopped

smClient:StringManager

i18n support for current client's locale

threadDumpback to summary
protected void threadDump(PrintWriter writer, StringManager smClient, Enumeration<Locale> requestedLocales)

Write a JVM thread dump.

Parameters
writer:PrintWriter

The output writer

smClient:StringManager

StringManager for the client's locale

requestedLocales:Enumeration<Locale>

the client's locales

tryAddServicedback to summary
protected boolean tryAddServiced(String name) throws Exception

Attempt to mark a context as being serviced

Parameters
name:String

The context name

Returns:boolean

true if the application was marked as being serviced and false if the application was already marked as being serviced

Exceptions
Exception:
Error invoking the deployer
undeployback to summary
protected void undeploy(PrintWriter writer, ContextName cn, StringManager smClient)

Undeploy the web application at the specified context path.

Parameters
writer:PrintWriter

Writer to render to

cn:ContextName

Name of the application to be removed

smClient:StringManager

i18n support for current client's locale

uploadWarback to summary
protected void uploadWar(PrintWriter writer, HttpServletRequest request, File war, StringManager smClient) throws IOException

Upload the WAR file included in this request, and store it at the specified file location.

Parameters
writer:PrintWriter

Writer to render to

request:HttpServletRequest

The servlet request we are processing

war:File

The file into which we should store the uploaded WAR

smClient:StringManager

The StringManager used to construct i18n messages based on the Locale of the client

Exceptions
IOException:
if an I/O error occurs during processing
validateContextNameback to summary
protected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager smClient)
vmInfoback to summary
protected void vmInfo(PrintWriter writer, StringManager smClient, Enumeration<Locale> requestedLocales)

Write some VM info.

Parameters
writer:PrintWriter

The output writer

smClient:StringManager

StringManager for the client's locale

requestedLocales:Enumeration<Locale>

the client's locales

writeDeployResultback to summary
private void writeDeployResult(PrintWriter writer, StringManager smClient, String name, String displayPath)