views:

199

answers:

4
+2  Q: 

Tomcat and VM

Hi,

I really confused in understanding where the tomcat actually runs. Is it execute inside the JVM, which execute servlets. Or it has it's own VM in executing servlet or JSP.

Thanks in advance.

+10  A: 

Tomcat will run within the JVM, and servlets execute within the Tomcat process (in the same JVM).

Running catalina.sh (or .bat) will start up a new JVM for Tomcat to run in. You can load/run Tomcat programatically within an existing JVM if you require a webserver as part of a bigger application.

Brian Agnew
A: 

Tomcat and it's servlets all run inside a JVM.

Cogsy
+1  A: 

Java provides the JVM to run any Java application.

Tomcat is essentially a Java program which implements the Servlet container specification and acts as a Servlet Container.

It also means you need (atleast) the Java JRE to run Tomcat.

lud0h
+1  A: 

This is a confusing subject as the "appearance of" separate JVMs is sometimes confused with different class loader instances.

Tomcat and your applications (WARs or servlets) share the same JVM, but they utilize independent class loaders - which is why you can have 2 WARs using different versions of something like log4J and all is good. Here's an article from O'Reilly about the class loader.

Vinnie