Apache Tomcat 7.0.4

org.apache.catalina.manager
Class HTMLManagerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.catalina.manager.ManagerServlet
              extended by org.apache.catalina.manager.HTMLManagerServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig, ContainerServlet

public final class HTMLManagerServlet
extends ManagerServlet

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 a 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

Version:
$Id: HTMLManagerServlet.java 1001915 2010-09-27 21:32:25Z markt $
Author:
Bip Thelin, Malcolm Edgar, Glenn L. Nielsen
See Also:
ManagerServlet, Serialized Form

Field Summary
protected static String APPLICATION_ERROR
           
protected static String APPLICATION_MESSAGE
           
protected static String sessionDetailJspPath
           
protected static String sessionsListJspPath
           
protected static URLEncoder URL_ENCODER
           
 
Fields inherited from class org.apache.catalina.manager.ManagerServlet
appBase, configBase, context, contextDescriptors, debug, deployed, global, host, mBeanServer, oname, sm, versioned, wrapper
 
Constructor Summary
HTMLManagerServlet()
           
 
Method Summary
protected  String deployInternal(String config, String path, String war)
          Deploy an application for the specified path from the specified web application archive.
protected  void displaySessionDetailPage(HttpServletRequest req, HttpServletResponse resp, String path, String sessionId)
           
protected  void displaySessionsListPage(String path, HttpServletRequest req, HttpServletResponse resp)
           
 void doGet(HttpServletRequest request, HttpServletResponse response)
          Process a GET request for the specified resource.
 void doPost(HttpServletRequest request, HttpServletResponse response)
          Process a POST request for the specified resource.
protected  void doSessions(String path, HttpServletRequest req, HttpServletResponse resp)
           
protected  String expireSessions(String path, HttpServletRequest req)
          Extract the expiration request parameter
protected  String findleaks()
          Find potential memory leaks caused by web application reload.
protected  String generateNonce()
          Generate a once time token (nonce) for authenticating subsequent requests.
protected  Comparator<Session> getComparator(String sortBy)
           
 String getServletInfo()
          Returns information about the servlet, such as author, version, and copyright.
protected  Session getSessionForPathAndId(String path, String id)
           
protected  List<Session> getSessionsForPath(String path)
           
 void init()
          Initialize this servlet.
 int invalidateSessions(String path, String[] sessionIds)
          Invalidate HttpSessions
 void list(HttpServletRequest request, HttpServletResponse response, String message)
          Render a HTML list of the currently active Contexts in our virtual host, and memory and server status information.
protected  String reload(String path)
          Reload the web application at the specified context path.
 boolean removeSessionAttribute(String path, String sessionId, String attributeName)
          Removes an attribute from an HttpSession
 String sessions(String path)
          Display session information and invoke list.
 String sessions(String path, int idle)
          Display session information and invoke list.
 int setSessionMaxInactiveInterval(String path, String sessionId, int maxInactiveInterval)
          Sets the maximum inactive interval (session timeout) an HttpSession
 String start(String path)
          Start the web application at the specified context path.
protected  String stop(String path)
          Stop the web application at the specified context path.
protected  String undeploy(String path)
          Undeploy the web application at the specified context path.
protected  String upload(HttpServletRequest request)
           
 
Methods inherited from class org.apache.catalina.manager.ManagerServlet
addServiced, check, copy, copyInternal, deploy, deploy, deploy, destroy, doPut, expireSessions, findleaks, getAppBase, getConfigFile, getDocBase, getWrapper, isDeployed, isServiced, list, printResources, reload, removeServiced, resources, roles, save, serverinfo, sessions, sessions, setWrapper, start, stop, undeploy, undeployDir, uploadWar
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_ENCODER

protected static final URLEncoder URL_ENCODER

APPLICATION_MESSAGE

protected static final String APPLICATION_MESSAGE
See Also:
Constant Field Values

APPLICATION_ERROR

protected static final String APPLICATION_ERROR
See Also:
Constant Field Values

sessionsListJspPath

protected static final String sessionsListJspPath
See Also:
Constant Field Values

sessionDetailJspPath

protected static final String sessionDetailJspPath
See Also:
Constant Field Values
Constructor Detail

HTMLManagerServlet

public HTMLManagerServlet()
Method Detail

doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
           throws IOException,
                  ServletException
Process a GET request for the specified resource.

Overrides:
doGet in class ManagerServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
Throws:
IOException - if an input/output error occurs
ServletException - if a servlet-specified error occurs
See Also:
ServletResponse.setContentType(java.lang.String)

doPost

public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
            throws IOException,
                   ServletException
Process a POST request for the specified resource.

Overrides:
doPost in class HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
Throws:
IOException - if an input/output error occurs
ServletException - if a servlet-specified error occurs
See Also:
ServletOutputStream, ServletResponse.setContentType(java.lang.String)

generateNonce

protected String generateNonce()
Generate a once time token (nonce) for authenticating subsequent requests. This will also add the token to the session. The nonce generation is a simplified version of ManagerBase.generateSessionId().


upload

protected String upload(HttpServletRequest request)
                 throws IOException,
                        ServletException
Throws:
IOException
ServletException

deployInternal

protected String deployInternal(String config,
                                String path,
                                String war)
Deploy an application for the specified path from the specified web application archive.

Parameters:
config - URL of the context configuration file to be deployed
path - Context path of the application to be deployed
war - URL of the web application archive to be deployed
Returns:
message String

list

public void list(HttpServletRequest request,
                 HttpServletResponse response,
                 String message)
          throws IOException
Render a HTML list of the currently active Contexts in our virtual host, and memory and server status information.

Parameters:
request - The request
response - The response
message - a message to display
Throws:
IOException

reload

protected String reload(String path)
Reload the web application at the specified context path.

Parameters:
path - Context path of the application to be restarted
Returns:
message String
See Also:
ManagerServlet.reload(PrintWriter, String)

undeploy

protected String undeploy(String path)
Undeploy the web application at the specified context path.

Parameters:
path - Context path of the application to be undeployed
Returns:
message String
See Also:
ManagerServlet.undeploy(PrintWriter, String)

sessions

public String sessions(String path,
                       int idle)
Display session information and invoke list.

Parameters:
path - Context path of the application to list session information
idle - Expire all sessions with idle time ≥ idle for this context
Returns:
message String
See Also:
ManagerServlet.sessions(PrintWriter, String, int)

sessions

public String sessions(String path)
Display session information and invoke list.

Parameters:
path - Context path of the application to list session information
Returns:
message String
See Also:
ManagerServlet.sessions(PrintWriter, String)

start

public String start(String path)
Start the web application at the specified context path.

Parameters:
path - Context path of the application to be started
Returns:
message String
See Also:
ManagerServlet.start(PrintWriter, String)

stop

protected String stop(String path)
Stop the web application at the specified context path.

Parameters:
path - Context path of the application to be stopped
Returns:
message String
See Also:
ManagerServlet.stop(PrintWriter, String)

findleaks

protected String findleaks()
Find potential memory leaks caused by web application reload.

Returns:
message String
See Also:
ManagerServlet.findleaks(PrintWriter)

getServletInfo

public String getServletInfo()
Description copied from class: javax.servlet.GenericServlet
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().

Specified by:
getServletInfo in interface Servlet
Overrides:
getServletInfo in class GenericServlet
Returns:
String information about this servlet, by default an empty string
See Also:
Servlet.getServletInfo()

init

public void init()
          throws ServletException
Description copied from class: ManagerServlet
Initialize this servlet.

Overrides:
init in class ManagerServlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation
See Also:
GenericServlet.init()

expireSessions

protected String expireSessions(String path,
                                HttpServletRequest req)
Extract the expiration request parameter

Parameters:
path -
req -

doSessions

protected void doSessions(String path,
                          HttpServletRequest req,
                          HttpServletResponse resp)
                   throws ServletException,
                          IOException
Parameters:
req -
resp -
Throws:
ServletException
IOException

getSessionsForPath

protected List<Session> getSessionsForPath(String path)

getSessionForPathAndId

protected Session getSessionForPathAndId(String path,
                                         String id)
                                  throws IOException
Throws:
IOException

displaySessionsListPage

protected void displaySessionsListPage(String path,
                                       HttpServletRequest req,
                                       HttpServletResponse resp)
                                throws ServletException,
                                       IOException
Parameters:
req -
resp -
Throws:
ServletException
IOException

displaySessionDetailPage

protected void displaySessionDetailPage(HttpServletRequest req,
                                        HttpServletResponse resp,
                                        String path,
                                        String sessionId)
                                 throws ServletException,
                                        IOException
Parameters:
req -
resp -
Throws:
ServletException
IOException

invalidateSessions

public int invalidateSessions(String path,
                              String[] sessionIds)
                       throws IOException
Invalidate HttpSessions

Parameters:
sessionIds -
Returns:
number of invalidated sessions
Throws:
IOException

removeSessionAttribute

public boolean removeSessionAttribute(String path,
                                      String sessionId,
                                      String attributeName)
                               throws IOException
Removes an attribute from an HttpSession

Parameters:
sessionId -
attributeName -
Returns:
true if there was an attribute removed, false otherwise
Throws:
IOException

setSessionMaxInactiveInterval

public int setSessionMaxInactiveInterval(String path,
                                         String sessionId,
                                         int maxInactiveInterval)
                                  throws IOException
Sets the maximum inactive interval (session timeout) an HttpSession

Parameters:
sessionId -
maxInactiveInterval - in seconds
Returns:
old value for maxInactiveInterval
Throws:
IOException

getComparator

protected Comparator<Session> getComparator(String sortBy)

Apache Tomcat 7.0.4

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.