0

I am developing a web application in java using the Vaadin framework.

I am running that application on Apache Tomcat. What I want to ask is that, if I run that application on Apache Tomcat and access the same application using two different browsers on two different computers, then does the application then have two instances on Tomcat or does it have a single instance?? I have searched for it, but not been able to find a satisfactory answer.

Thanks !

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
Muhammad Salman Farooq
  • 1,325
  • 9
  • 26
  • 54
  • 3
    I don't do Vaadin, but since it's as almost every other 3rd party Java EE web MVC framework built on top of the Servlet API, this answer may be what you're looking for: http://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-session-variables-and-multithreading/3106909#3106909 – BalusC Jun 25 '12 at 20:02

2 Answers2

3

If you run a web application in Tomcat, you'll have exactly one Tomcat instance, which will host your application. This single Tomcat instance (and therefore your web application) will be able to many different browser requests, from many different computers. This is exactly what web servers are designed to do: process requests from many different clients.

Tom
  • 1,414
  • 12
  • 21
1

One instance of Tomcat, and many instances of your Vaadin app.

To access your Vaadin app, the user points their web browser to your Vaadin app's URL. Tomcat must already be running in order to accept the request from the web browser. When the already-running instance of Tomcat receives that request, Tomcat starts a new thread. In that thread a new instance of your subclass of the Vaadin "Application" class will be created and run.

So, if you have 5 simultaneous users running your Vaadin app, you will have one instance of Tomcat running. And that Tomcat instance will be running 5 sessions, each in its own thread running its own instance of your Vaadin "Application" subclass.

Anything marked "static" in your app applies to all 5 instances of your app, while anything not marked "static" applies only to a single instance of your app (a single user).

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154