public class HostManagerServlet extends HttpServlet implements ContainerServlet
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:
host-name
attribute
indicates the name of the new host. The host-aliases
attribute is a comma separated list of the host alias names.
The manager
attribute is a boolean value indicating if the
webapp manager will be installed in the newly created host (optional,
false by default).host-name
attribute indicates the name of the host.
host-name#host-aliases
.NOTE - Attempting to stop or remove the host containing this servlet itself will not succeed. Therefore, this servlet should generally be deployed in a separate virtual host.
The following servlet initialization parameters are recognized:
Modifier and Type | Field and Description |
---|---|
protected Context |
context
The Context container associated with our web application.
|
protected int |
debug
The debugging detail level for this servlet.
|
protected Engine |
engine
The associated engine.
|
protected Host |
installedHost
The associated host.
|
protected MBeanServer |
mBeanServer
MBean server.
|
protected static StringManager |
sm
The string manager for this package.
|
protected Wrapper |
wrapper
The Wrapper container associated with this servlet.
|
Constructor and Description |
---|
HostManagerServlet() |
Modifier and Type | Method and Description |
---|---|
protected void |
add(HttpServletRequest request,
PrintWriter writer,
String name,
boolean htmlMode,
StringManager smClient)
Add host with the given parameters.
|
protected void |
add(PrintWriter writer,
String name,
String aliases,
String appBase,
boolean manager,
boolean autoDeploy,
boolean deployOnStartup,
boolean deployXML,
boolean unpackWARs,
boolean copyXML,
StringManager smClient)
Add a host using the specified parameters.
|
protected boolean |
booleanParameter(HttpServletRequest request,
String parameter,
boolean theDefault,
boolean htmlMode)
Extract boolean value from checkbox with default.
|
void |
destroy()
Finalize this servlet.
|
void |
doGet(HttpServletRequest request,
HttpServletResponse response)
Process a GET request for the specified resource.
|
protected File |
getConfigBase(String hostName)
Get config base.
|
protected StringManager |
getStringManager(HttpServletRequest req)
Deprecated.
Use
StringManager.getManager(String, Enumeration) .
This method will be removed in Tomcat 8. |
Wrapper |
getWrapper()
Return the Wrapper with which we are associated.
|
void |
init()
A convenience method which can be overridden so that there's no need to
call
super.init(config) . |
protected void |
list(PrintWriter writer,
StringManager smClient)
Render a list of the currently active Contexts in our virtual host.
|
protected void |
remove(PrintWriter writer,
String name,
StringManager smClient)
Remove the specified host.
|
void |
setWrapper(Wrapper wrapper)
Set the Wrapper with which we are associated.
|
protected void |
start(PrintWriter writer,
String name,
StringManager smClient)
Start the host with the specified name.
|
protected void |
stop(PrintWriter writer,
String name,
StringManager smClient)
Stop the host with the specified name.
|
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
protected transient Context context
protected int debug
protected transient Host installedHost
protected transient Engine engine
protected transient MBeanServer mBeanServer
protected static final StringManager sm
protected transient Wrapper wrapper
public Wrapper getWrapper()
getWrapper
in interface ContainerServlet
public void setWrapper(Wrapper wrapper)
setWrapper
in interface ContainerServlet
wrapper
- The new wrapperpublic void destroy()
destroy
in interface Servlet
destroy
in class GenericServlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doGet
in class HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
- if an input/output error occursServletException
- if a servlet-specified error occursServletResponse.setContentType(java.lang.String)
protected void add(HttpServletRequest request, PrintWriter writer, String name, boolean htmlMode, StringManager smClient)
request
- The requestwriter
- The output writername
- The host namehtmlMode
- Flag valuesmClient
- StringManager for the client's localeprotected boolean booleanParameter(HttpServletRequest request, String parameter, boolean theDefault, boolean htmlMode)
request
- The Servlet requestparameter
- The parameter nametheDefault
- Default valuehtmlMode
- Flag valuepublic void init() throws ServletException
GenericServlet
super.init(config)
.
Instead of overriding GenericServlet.init(ServletConfig)
, simply override this
method and it will be called by
GenericServlet.init(ServletConfig config)
. The
ServletConfig
object can still be retrieved via
GenericServlet.getServletConfig()
.
init
in class GenericServlet
ServletException
- if an exception occurs that interrupts the servlet's
normal operationprotected void add(PrintWriter writer, String name, String aliases, String appBase, boolean manager, boolean autoDeploy, boolean deployOnStartup, boolean deployXML, boolean unpackWARs, boolean copyXML, StringManager smClient)
writer
- Writer to render results toname
- host namealiases
- comma separated alias listappBase
- application base for the hostmanager
- should the manager webapp be deployed to the new host ?autoDeploy
- Flag valuedeployOnStartup
- Flag valuedeployXML
- Flag valueunpackWARs
- Flag valuecopyXML
- Flag valuesmClient
- StringManager for the client's localeprotected void remove(PrintWriter writer, String name, StringManager smClient)
writer
- Writer to render results toname
- host namesmClient
- StringManager for the client's localeprotected void list(PrintWriter writer, StringManager smClient)
writer
- Writer to render tosmClient
- StringManager for the client's localeprotected void start(PrintWriter writer, String name, StringManager smClient)
writer
- Writer to render toname
- Host namesmClient
- StringManager for the client's localeprotected void stop(PrintWriter writer, String name, StringManager smClient)
writer
- Writer to render toname
- Host namesmClient
- StringManager for the client's localeprotected File getConfigBase(String hostName)
hostName
- The host name@Deprecated protected StringManager getStringManager(HttpServletRequest req)
StringManager.getManager(String, Enumeration)
.
This method will be removed in Tomcat 8.Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.