1

I'm having hard time googling this so I hope somebody would give me some light. If my question is off please put me in the right direction.

I have two web applications. They are hosted in one Tomcat server instance. Each can be accessed using the same port.

How is the JVM of the server look like? Will the server contain two different instance of JVM, one per each web application. Thank you in advance.

2 Answers 2

2

The AppServer runs on one JVM. It is optimized to run multiple applications and this is done in a threaded way. Please note that I am not considering clustering in this answer.

The AppServer takes a request, it checks it's farm to see if the Web application is present and if it does exist, checks it's web.xml to check if a path to a requested servlet exists. If all goes fine, the AppServer spawns a new thread (or uses an existing one from the thread pool which is configurable at the AppServer level) and assigns the thread to handle the servlet thus catering to the user.

Sign up to request clarification or add additional context in comments.

Comments

1

If they're hosted on one Tomcat instance then they'll be running on the same JVM.

7 Comments

Does this mean that, two clients that access the same web application in one tomcat instance will also share one JVM?
The code will run within the same JVM, yes, although obviously if they're accessing via a Java system then the calling systems will not necessarily share a JVM.
Suppose a click on a button in a jsp sends a request to the server and the server directs it to the servlet, the servlet creates a list of data. In which JVM will this list reside?
The list will be in whichever JVM the servlet was running in, so the JVM that your Tomcat server is running in.
Does it mean that if 5 clients are accesing the same servlet, the JVM that runs the servlet will contain 5 list instances each unique to each servlet???
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.