Restarting Applications Without Restarting Tomcat
If you modify a JSP page, Tomcat recompiles it automatically when the page is next requested. But if the page uses a JAR or class file under the application’s WEB-INF directory and you update one of them, Tomcat normally won’t notice the change until you restart it.
One way to avoid restarts for an application is to provide
a
<Context>
element for the application in Tomcat’s server.xml file that specifies a reloadable
attribute of true
. That will cause Tomcat to look for
changes not only in JSP pages that are requested directly, but also for
changes in classes and libraries under the WEB-INF directory that the pages use. For
example, to write such a <Context>
element for an application
named mcb
, you could add a line like
this to Tomcat’s server.xml
file:
<Context path="/mcb" docBase="mcb" debug="0" reloadable="true"/>
The <Context>
element
attributes tell Tomcat four things:
-
path
Indicates the URL that maps to pages from the application context. The value is the part of the URL that follows the hostname and port number.
-
docBase
Indicates where the application context directory is located, relative to the webapps directory in the Tomcat tree.
-
debug
Sets the context debugging level. A value of zero disables debug output; higher numbers generate more output.
-
reloadable
Specifies Tomcat recompilation behavior when a client requests a JSP page located in the application context. By default, Tomcat recompiles a page only after noticing a ...
Get MySQL Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.