• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Number Of Web Containers in Tomcat?

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I will be deploying multiple war files in the tomcat.

Will each war file will be deployed in separate web container or there will be only ONE web container for whole tomcat

Thanks
 
Saloon Keeper
Posts: 28124
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That kind of depends on what your definition of "web container" is.

Tomcat is a (limited) JEE-compliant web application container. As such, it implements one or more Hosts and each Host can contain zero or more web applications (WAR deployments). Tomcat provides the communications interfaces and protocols (http, https, and so forth), and once a URL request is received, the URL is dissected to determine which Host gets the request. The Host then looks at the URL context path component to determine which webapp gets the request, and checks the webapp's servlet mapping (defined in its web.xml and/or annotations) to know what application logic will be selected to process the request.

Tomcat itself is a single JVM implementation with its own internal object space. It is, in fact, a bog-standard Java Application that just happens to be an assemblage of JavaBeans designed to listen on the network and process and dispatch incoming requests, as well as routing the responses to those requests back to the requester.

Within Tomcat, various subsystems exist with unique internal classpaths. Most of them you do not care about, but each webapp's classpath includes its WEB-INF/classes and WEB-INF/lib resources and no one else's. Effectively, each webapp runs in a sort of virtual machine independent of any other webapp.
 
Chris Mary
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim,

Attached the tomcat web container diagram..
Let me now whether the web container can be duplicated.
When multiple war is put in the webapps folder, it would have jsp. servlet, html file separately

Thanks

tomcat.jpg
[Thumbnail for tomcat.jpg]
 
Chris Mary
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also,

Java Web Container = Servlet Container + JSP Container

However the attached diagram has many web apps but one servlet container instance....

web-server-architecture.jpg
[Thumbnail for web-server-architecture.jpg]
 
Tim Holloway
Saloon Keeper
Posts: 28124
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat, as I said, is a container/server for web applications. And also, as mentioned, multiple web applications can be hosted from a single instance of Tomcat.  Some of the stock Tomcat distributions in fact, have several webapps pre-installed when you unzip Tomcat after downloading. You can see them in the TOMCAT_HOME/webapps directory. Most correspond to their URL context paths, although the special name ROOT maps to the "/" URL context path, since "/" is not a valid path name.

You can host multiple instances of Tomcat in the same host machine (OS instance), be it physical or virtual, although due to limitations in TCP/IP, each instance has to use a different set of ports (as defined in TOMCAT_HOME/conf/server.xml).

Tomcat can also run containerized as multiple container instances, which makes it useful for things like elastic cloud apps.
 
Chris Mary
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim,

I understand it can container multiple apps or multiple instances.

But i am trying to understand what a web container and how many web container a single tomcat hold?

Some website says Tomcat is a web container => Is it single or multiple?
 
Saloon Keeper
Posts: 7633
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have always found the term "web container" to be rather pointless and confusing. Nobody outside the Java community uses it, and even within the community you rarely see it, especially not in the last 15 years or so. "JSP container" as well is a rarely used term - "servlet container" much more so. Not that it makes much sense to distinguish between a servlet container and a JSP container, since JSPs are implemented in terms of servlets, so both are one and the same.
 
Tim Holloway
Saloon Keeper
Posts: 28124
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also have absolutely no idea what a "web container" is supposed to be either. As I said from the start. Tomcat is a container/server for web applications and that's all that need be said. What are these "web" thingies supposed to be???

As for "servlet container", "JSP container", that's not much better. Because JSPs are compiled by the container to servlet form internally, any JSP container is automatically a servlet container, and I've certainly never heard of a servlet-only container since JSPs first came out, as it's relatively easy to add that function to a servlet sysem.

There is such a thing as a servlet/jsp container, and that's what Tomcat and jetty are. The term is used to distinquish them from full-stack JEE servers like WebSphere, WebLogic, Wildfly and so forth.

Even that is a misnomer. While "servlet/jsp containers" may not have EJBs, javamail, support for EARs and other advanced JEE features built in, they do have integrated JNDI servers, database connection pool support and other essential JEE services.

So if you want to know how many "web containers" Tomcat holds, make up a number, because the rest of us don't know or admittedly care what that term means. Tomcat can hold as many Hosts and web applications as your system memory will allow you to cram in. There is no fixed limit. That is what we care about.
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic