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

public final Class HTMLManagerServlet

extends ManagerServlet
Class Inheritance
Imports
java.io.File, .IOException, .PrintWriter, .StringWriter, java.net.InetAddress, .UnknownHostException, java.nio.charset.StandardCharsets, java.text.MessageFormat, java.util.ArrayList, .Arrays, .Collections, .Comparator, .List, .Locale, .Set, java.util.function.Function, jakarta.servlet.ServletException, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, .HttpSession, .Part, org.apache.catalina.Container, .Context, .DistributedManager, .Manager, .Session, org.apache.catalina.manager.util.SessionUtils, org.apache.catalina.util.ContextName, .ServerInfo, .URLEncoder, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.security.Escape

Servlet that enables remote management of the web applications deployed 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.

The difference between the ManagerServlet and this Servlet is that this Servlet prints out an HTML interface which makes it easier to administrate.

However if you use a software that parses the output of ManagerServlet you won't be able to upgrade to this Servlet since the output are not in the same format ar from ManagerServlet

Authors
Bip Thelin, Malcolm Edgar, Glenn L. Nielsen
See Also
ManagerServlet

Field Summary

Modifier and TypeField and Description
pack-priv static final String
pack-priv static final String
private static final String
private static final String
private static final String
pack-priv static final String
pack-priv static final String
pack-priv static final String
private static final String
private static final String
private static final String
private static final long
pack-priv static final String
pack-priv static final String
private boolean
private static final String
private static final String
private static final String
private static final String
private static final String
Inherited from org.apache.catalina.manager.ManagerServlet:
configBasecontextdebugglobalhostmBeanServeronamesmversionedwrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static <U extends Comparable<? super U>> Comparator<Session>
comparingNullable(Function<Session, ? extends U> keyExtractor)

protected String

Returns:

message String
deployInternal
(String
URL of the context configuration file to be deployed
config
,
ContextName
Name of the application to be deployed
cn
,
String
URL of the web application archive to be deployed
war
,
StringManager
internationalized strings
smClient
)

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

protected void
displaySessionDetailPage(HttpServletRequest
The Servlet request
req
,
HttpServletResponse
The Servlet response
resp
,
ContextName
Name of the application for which the sessions will be listed
cn
,
String
the session id
sessionId
,
StringManager
StringManager for the client's locale
smClient
)

Display session details.

protected void
displaySessionsListPage(ContextName
Name of the application for which the sessions will be listed
cn
,
HttpServletRequest
The Servlet request
req
,
HttpServletResponse
The Servlet response
resp
,
StringManager
StringManager for the client's locale
smClient
)

List session.

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

Overrides org.apache.catalina.manager.ManagerServlet.doGet.

Process a GET request for the specified resource.

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

Overrides jakarta.servlet.http.HttpServlet.doPost.

Process a POST request for the specified resource.

protected void
doSessions(ContextName
Name of the application for the sessions operation
cn
,
HttpServletRequest
The Servlet request
req
,
HttpServletResponse
The Servlet response
resp
,
StringManager
StringManager for the client's locale
smClient
)

Handle session operations.

protected String

Returns:

message string
expireSessions
(ContextName
Name of the application from which to expire sessions
cn
,
HttpServletRequest
The Servlet request
req
,
StringManager
StringManager for the client's locale
smClient
)

Extract the expiration request parameter

protected String

Returns:

message String
findleaks
(StringManager
StringManager for the client's locale
smClient
)

Find potential memory leaks caused by web application reload.

protected Comparator<Session>
public String
getServletInfo()

Overrides jakarta.servlet.GenericServlet.getServletInfo.

Implements jakarta.servlet.Servlet.getServletInfo.

Returns information about the servlet, such as author, version, and copyright.

protected Session
protected List<Session>
public void
init()

Overrides org.apache.catalina.manager.ManagerServlet.init.

Initialize this servlet.

protected int

Returns:

number of invalidated sessions
invalidateSessions
(ContextName
Name of the application for which sessions are to be invalidated
cn
,
String[]
the session ids of the sessions
sessionIds
,
StringManager
StringManager for the client's locale
smClient
)

Invalidate specified sessions.

protected void
list(HttpServletRequest
The request
request
,
HttpServletResponse
The response
response
,
String
a message to display
message
,
StringManager
internationalized strings
smClient
)

Render an HTML list of the currently active Contexts in our virtual host, and memory and server status information.

protected String

Returns:

message String
reload
(ContextName
Name of the application to be restarted
cn
,
StringManager
StringManager for the client's locale
smClient
)

Reload the web application at the specified context path.

protected boolean

Returns:

true if there was an attribute removed, false otherwise
removeSessionAttribute
(ContextName
Name of the application hosting the session from which the attribute is to be removed
cn
,
String
the session id
sessionId
,
String
the attribute name
attributeName
,
StringManager
StringManager for the client's locale
smClient
)

Removes an attribute from an HttpSession

protected String

Returns:

message String
sessions
(ContextName
Name of the application to list session information
cn
,
int
Expire all sessions with idle time ≥ idle for this context
idle
,
StringManager
StringManager for the client's locale
smClient
)

Display session information and invoke list.

protected void
protected void
protected void
protected String
sslReload(String tlsHostName, StringManager smClient)

protected String

Returns:

message String
start
(ContextName
Name of the application to be started
cn
,
StringManager
StringManager for the client's locale
smClient
)

Start the web application at the specified context path.

protected String

Returns:

message String
stop
(ContextName
Name of the application to be stopped
cn
,
StringManager
StringManager for the client's locale
smClient
)

Stop the web application at the specified context path.

protected String

Returns:

message String
undeploy
(ContextName
Name of the application to be undeployed
cn
,
StringManager
StringManager for the client's locale
smClient
)

Undeploy the web application at the specified context path.

protected String
Inherited from org.apache.catalina.manager.ManagerServlet:
checkdeploydeploydeploydestroydoPutexpireSessionsfindleaksgetConnectorCertsgetConnectorCiphersgetConnectorTrustedCertsgetWrapperisDeployedlistprintResourcesreloadremoveServicedresourcessaveserverinfosessionssetWrappersslConnectorCipherssslReloadstartstopthreadDumptryAddServicedundeployuploadWarvalidateContextNamevmInfo

Field Detail

APPLICATION_ERRORback to summary
pack-priv static final String APPLICATION_ERROR
APPLICATION_MESSAGEback to summary
pack-priv static final String APPLICATION_MESSAGE
APPS_HEADER_SECTIONback to summary
private static final String APPS_HEADER_SECTION
APPS_ROW_DETAILS_SECTIONback to summary
private static final String APPS_ROW_DETAILS_SECTION
CONFIG_SECTIONback to summary
private static final String CONFIG_SECTION
connectorCertsJspPathback to summary
pack-priv static final String connectorCertsJspPath
connectorCiphersJspPathback to summary
pack-priv static final String connectorCiphersJspPath
connectorTrustedCertsJspPathback to summary
pack-priv static final String connectorTrustedCertsJspPath
DEPLOY_SECTIONback to summary
private static final String DEPLOY_SECTION
DIAGNOSTICS_SECTIONback to summary
private static final String DIAGNOSTICS_SECTION
MANAGER_APP_ROW_BUTTON_SECTIONback to summary
private static final String MANAGER_APP_ROW_BUTTON_SECTION
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.catalina.manager.ManagerServlet.serialVersionUID.

sessionDetailJspPathback to summary
pack-priv static final String sessionDetailJspPath
sessionsListJspPathback to summary
pack-priv static final String sessionsListJspPath
showProxySessionsback to summary
private boolean showProxySessions
STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTIONback to summary
private static final String STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION
STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTIONback to summary
private static final String STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION
STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTIONback to summary
private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION
STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTIONback to summary
private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION
UPLOAD_SECTIONback to summary
private static final String UPLOAD_SECTION

Constructor Detail

HTMLManagerServletback to summary
public HTMLManagerServlet()

Method Detail

comparingNullableback to summary
private static <U extends Comparable<? super U>> Comparator<Session> comparingNullable(Function<Session, ? extends U> keyExtractor)
deployInternalback to summary
protected String deployInternal(String config, ContextName cn, String war, StringManager smClient)

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

Parameters
config:String

URL of the context configuration file to be deployed

cn:ContextName

Name of the application to be deployed

war:String

URL of the web application archive to be deployed

smClient:StringManager

internationalized strings

Returns:String

message String

displaySessionDetailPageback to summary
protected void displaySessionDetailPage(HttpServletRequest req, HttpServletResponse resp, ContextName cn, String sessionId, StringManager smClient) throws ServletException, IOException

Display session details.

Parameters
req:HttpServletRequest

The Servlet request

resp:HttpServletResponse

The Servlet response

cn:ContextName

Name of the application for which the sessions will be listed

sessionId:String

the session id

smClient:StringManager

StringManager for the client's locale

Exceptions
ServletException:
Propagated Servlet error
IOException:
An IO error occurred
displaySessionsListPageback to summary
protected void displaySessionsListPage(ContextName cn, HttpServletRequest req, HttpServletResponse resp, StringManager smClient) throws ServletException, IOException

List session.

Parameters
cn:ContextName

Name of the application for which the sessions will be listed

req:HttpServletRequest

The Servlet request

resp:HttpServletResponse

The Servlet response

smClient:StringManager

StringManager for the client's locale

Exceptions
ServletException:
Propagated Servlet error
IOException:
An IO error occurred
doGetback to summary
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

Overrides org.apache.catalina.manager.ManagerServlet.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
doPostback to summary
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

Overrides jakarta.servlet.http.HttpServlet.doPost.

Process a POST 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
doSessionsback to summary
protected void doSessions(ContextName cn, HttpServletRequest req, HttpServletResponse resp, StringManager smClient) throws ServletException, IOException

Handle session operations.

Parameters
cn:ContextName

Name of the application for the sessions operation

req:HttpServletRequest

The Servlet request

resp:HttpServletResponse

The Servlet response

smClient:StringManager

StringManager for the client's locale

Exceptions
ServletException:
Propagated Servlet error
IOException:
An IO error occurred
expireSessionsback to summary
protected String expireSessions(ContextName cn, HttpServletRequest req, StringManager smClient)

Extract the expiration request parameter

Parameters
cn:ContextName

Name of the application from which to expire sessions

req:HttpServletRequest

The Servlet request

smClient:StringManager

StringManager for the client's locale

Returns:String

message string

findleaksback to summary
protected String findleaks(StringManager smClient)

Find potential memory leaks caused by web application reload.

Parameters
smClient:StringManager

StringManager for the client's locale

Returns:String

message String

See Also
ManagerServlet#findleaks(boolean, PrintWriter, StringManager)
getComparatorback to summary
protected Comparator<Session> getComparator(String sortBy)
getServletInfoback to summary
public String getServletInfo()

Overrides jakarta.servlet.GenericServlet.getServletInfo.

Implements jakarta.servlet.Servlet.getServletInfo.

Doc from jakarta.servlet.GenericServlet.getServletInfo.

Returns information about the servlet, such as author, version, and copyright. By default, this method returns an empty string. Override this method to have it return a meaningful value. See Servlet#getServletInfo.

Returns:String

String information about this servlet, by default an empty string

Annotations
@Override
See Also
jakarta.servlet.Servlet#getServletInfo()
getSessionForNameAndIdback to summary
protected Session getSessionForNameAndId(ContextName cn, String id, StringManager smClient)
getSessionsForNameback to summary
protected List<Session> getSessionsForName(ContextName cn, StringManager smClient)
initback to summary
public void init() throws ServletException

Overrides org.apache.catalina.manager.ManagerServlet.init.

Doc from org.apache.catalina.manager.ManagerServlet.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

See Also
jakarta.servlet.GenericServlet#init()
invalidateSessionsback to summary
protected int invalidateSessions(ContextName cn, String[] sessionIds, StringManager smClient)

Invalidate specified sessions.

Parameters
cn:ContextName

Name of the application for which sessions are to be invalidated

sessionIds:String[]

the session ids of the sessions

smClient:StringManager

StringManager for the client's locale

Returns:int

number of invalidated sessions

listback to summary
protected void list(HttpServletRequest request, HttpServletResponse response, String message, StringManager smClient) throws IOException

Render an HTML list of the currently active Contexts in our virtual host, and memory and server status information.

Parameters
request:HttpServletRequest

The request

response:HttpServletResponse

The response

message:String

a message to display

smClient:StringManager

internationalized strings

Exceptions
IOException:
an IO error occurred
reloadback to summary
protected String reload(ContextName cn, StringManager smClient)

Reload the web application at the specified context path.

Parameters
cn:ContextName

Name of the application to be restarted

smClient:StringManager

StringManager for the client's locale

Returns:String

message String

See Also
ManagerServlet#reload(PrintWriter, ContextName, StringManager)
removeSessionAttributeback to summary
protected boolean removeSessionAttribute(ContextName cn, String sessionId, String attributeName, StringManager smClient)

Removes an attribute from an HttpSession

Parameters
cn:ContextName

Name of the application hosting the session from which the attribute is to be removed

sessionId:String

the session id

attributeName:String

the attribute name

smClient:StringManager

StringManager for the client's locale

Returns:boolean

true if there was an attribute removed, false otherwise

sessionsback to summary
protected String sessions(ContextName cn, int idle, StringManager smClient)

Display session information and invoke list.

Parameters
cn:ContextName

Name of the application to list session information

idle:int

Expire all sessions with idle time ≥ idle for this context

smClient:StringManager

StringManager for the client's locale

Returns:String

message String

See Also
ManagerServlet#sessions(PrintWriter, ContextName, int, StringManager)
sslConnectorCertsback to summary
protected void sslConnectorCerts(HttpServletRequest request, HttpServletResponse response, StringManager smClient) throws ServletException, IOException
sslConnectorCiphersback to summary
protected void sslConnectorCiphers(HttpServletRequest request, HttpServletResponse response, StringManager smClient) throws ServletException, IOException
sslConnectorTrustedCertsback to summary
protected void sslConnectorTrustedCerts(HttpServletRequest request, HttpServletResponse response, StringManager smClient) throws ServletException, IOException
sslReloadback to summary
protected String sslReload(String tlsHostName, StringManager smClient)
startback to summary
protected String start(ContextName cn, StringManager smClient)

Start the web application at the specified context path.

Parameters
cn:ContextName

Name of the application to be started

smClient:StringManager

StringManager for the client's locale

Returns:String

message String

See Also
ManagerServlet#start(PrintWriter, ContextName, StringManager)
stopback to summary
protected String stop(ContextName cn, StringManager smClient)

Stop the web application at the specified context path.

Parameters
cn:ContextName

Name of the application to be stopped

smClient:StringManager

StringManager for the client's locale

Returns:String

message String

See Also
ManagerServlet#stop(PrintWriter, ContextName, StringManager)
undeployback to summary
protected String undeploy(ContextName cn, StringManager smClient)

Undeploy the web application at the specified context path.

Parameters
cn:ContextName

Name of the application to be undeployed

smClient:StringManager

StringManager for the client's locale

Returns:String

message String

See Also
ManagerServlet#undeploy(PrintWriter, ContextName, StringManager)
uploadback to summary
protected String upload(HttpServletRequest request, StringManager smClient)