7
votes

I've some doubt about tomcat operation which come across my webapp development:

  1. Is there any way to shutdown tomcat itself from the webapp deployed in it?
  2. Is tomcat is running all of its webapps/war inside one JVM or individual JVM or its configurable in some configuration file?
  3. Is it possible to increase the java heap size for particular webapp deployed inside tomcat?

Thanks a lot.

1

1 Answers

7
votes
  1. Open TCP connection from some servlet and send "SHUTDOWN" to Tomcat's shutdown port (default: 8005).
  2. One Tomcat uses one JVM for all applications.
  3. No. Only for the entire JVM.

Here's code for point 1:

Socket clientSocket = new Socket("localhost", 8005);
clientSocket.getOutputStream().write("SHUTDOWN".getBytes());
clientSocket.getOutputStream().close();
clientSocket.close();