简体   繁体   English

Apache Tomcat上的Java Web应用程序

[英]Java web application on apache tomcat

I am developing a web application in java using the Vaadin framework. 我正在使用Vaadin框架在Java中开发Web应用程序。

I am running that application on Apache Tomcat. 我正在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?? 我想问的是,如果我在Apache Tomcat上运行该应用程序,并在两台不同的计算机上使用两个不同的浏览器访问同一应用程序,那么该应用程序在Tomcat上有两个实例,还是只有一个实例? I have searched for it, but not been able to find a satisfactory answer. 我已经搜索过了,但是找不到满意的答案。

Thanks ! 谢谢 !

If you run a web application in Tomcat, you'll have exactly one Tomcat instance, which will host your application. 如果在Tomcat中运行Web应用程序,则将只有一个Tomcat实例,它将托管您的应用程序。 This single Tomcat instance (and therefore your web application) will be able to many different browser requests, from many different computers. 这个Tomcat实例(以及您的Web应用程序)将能够处理来自许多不同计算机的许多不同浏览器请求。 This is exactly what web servers are designed to do: process requests from many different clients. 这正是Web服务器设计的目的:处理来自许多不同客户端的请求。

One instance of Tomcat, and many instances of your Vaadin app. Tomcat的一个实例,以及Vaadin应用程序的许多实例。

To access your Vaadin app, the user points their web browser to your Vaadin app's URL. 要访问您的Vaadin应用,用户将其Web浏览器指向您的Vaadin应用的URL。 Tomcat must already be running in order to accept the request from the web browser. Tomcat必须已经在运行,才能接受来自Web浏览器的请求。 When the already-running instance of Tomcat receives that request, Tomcat starts a new thread. 当已经在运行的Tomcat实例收到该请求时,Tomcat将启动一个新线程。 In that thread a new instance of your subclass of the Vaadin "Application" class will be created and run. 在该线程中,将创建并运行Vaadin“ Application”类的子类的新实例。

So, if you have 5 simultaneous users running your Vaadin app, you will have one instance of Tomcat running. 因此,如果同时有5位用户在运行Vaadin应用程序,则将有一个Tomcat实例在运行。 And that Tomcat instance will be running 5 sessions, each in its own thread running its own instance of your Vaadin "Application" subclass. 那个Tomcat实例将运行5个会话,每个会话在其自己的线程中运行自己的Vaadin“ Application”子类实例。

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). 应用中标记为“静态”的所有内容都适用于您应用的所有5个实例,而未标记为“静态”的所有内容均仅适用于您应用的单个实例(单个用户)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM