Tomcat Web Server

Is Tomcat is a web server or an application server? Let me tell you how I convinced my self regarding this.

Join the DZone community and get the full member experience.

Join For Free

Tomcat The Tomcat server is the most widely used open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language, and Java WebSocket technologies. Apache Tomcat software powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations. Tomcat, formerly known as Jakarta Tomcat, is an open web server solution and servlet container developed by the Apache Software Foundation. Tomcat is written in Java. In fact, Tomcat uses Java Servlet to provide a pure Java server environment for running your code.

The Tomcat server comes to your aide in monitoring performance by providing JMX beans for most of these metrics that you can verify using a tool like Tomcat Manager or JavaMelody. To continue this article, we’re going to take a look at each area of Tomcat performance, any MBeans definitions that can help monitor it and how you can view their.

Many application developers do not focus much on the infrastructure on which their code runs. When it comes to web applications there are common confusions like what is the difference between webserver and applications server or when to go for a EAR vs WAR file deployment etc..

There are many good answers that differentiate between web servers and applications servers like this one. Most of the times the terms Web Server and Application server are used interchangeably. This article explains the working of a typical web server. Typically we get confused with the example of Tomcat Server (an example for a web server) having the capability to run the enterprise applications. So, tomcat is a web server or an application server? Let me tell you how I convinced my self regarding this.

Some time back I was struck with the question What's the difference between JPA and Hibernate on stack overflow. I did answer it, but one of the comment lead me to a more detailed understanding of the JavaEE spec and certified servers. If you can understand this then differentiating between the web server and application server is easy. During my investigations I got this article, which discusses the advantages of both.

Tomcat Web Server

A more detailed look in to the meaning JavaEE specification will throw some light in to our discussions. As we know specifications are set of rules. Simply put they contain the interface. Any JavaEE servers which needs to comply to spec needs to have the implementation of these interfaces. You can find the certified JavaEE servers list here. If you are deploying your enterprise applications (means you have JPA, EJB or some technology which is part of Java EE) to the a server which comply to JavaEE then the lib need not contain the API implementation jars. But these are needed if you are using a web server like tomcat for deployment.

For example, if you use JPA in your applications and deploying it to the Jboss AS 7, then you need any additional jars in the lib. But the same application you want to deploy to the tomcat server then you need to have additional jars to lib that implements the JPA spec may be eclipselink or Hibernate. This is what makes JBoss AS 7 an application server and tomcat a web server. Another key difference is that we can not deploy an EAR file to tomcat, it could only handle WAR files. Dmg can't find original.

java,server-side

Tomcat Web Server Download

Published at DZone with permission of Manu Pk. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

To deploy a web application to Apache Tomcat, you can copy a WAR file to the application base directory, e.g., c:/Tomcat8/webapps. This operation of course presupposes we know the application base directory. We could consult server.xml and look up the Host element to determine the directory name. A more straightforward approach, though, is to use the Tomcat manager web application.

Tomcat Web Server

To learn how to deploy a web application using the Apache Tomcat manager web application, follow these 12 steps:

Tomcat Web Server Tutorial

  1. Stop the Tomcat server.
  2. You will need to edit CATALINA_BASE/conf/tomcat-users.xml, e.g., c:/Tomcat8/conf/tomcat-users.xml to add credentials to access the Tomcat manager web application.
  3. Add the following XML statements immediately before the root end tag, i.e., </tomcat-users>: Replace 'your name' and 'your password' with a user name and password of your choosing (no embedded spaces).
  4. Save your changes.
  5. You'll need to create a WAR file so that you will have web application to deploy. The instructions for creating a WAR file were contained in steps 1 and 2 in How to deploy a WAR file in Apache Tomcat (Windows). Complete only steps 1 and 2. If you have already completed that project, delete the WAR file (DemoWebsite.war) and the unpacked folder (DemoWebsite) from CATALINA_HOME/webapps.
  6. Start the Tomcat server.
  7. In the address area of your browser, type http://localhost:8080/manager/html and submit that address to the browser.
  8. You will be challenged for credentials. Provide the user name and password you specified in tomcat-users.xml (make sure to provide the correct spelling and case):
    Click OK
  9. The manager web page is now displayed. Scroll down until you see the Deploy section:
    Note that I have already provided the Context Path (/DemoWebsite) and the WAR URL ((c:/DemoWebsite/DemoWebsite.war) in the text boxes. Fill in the text boxes as I've done. Then click Deploy.
  10. The manager will indicate that the web site has been deployed:
  11. In a separate tab in your browser, type http://localhost:8080/DemoWebsite/DateJSP.jsp and submit that address to the browser.
  12. The web page will be displayed verifying successful deployment: