Skip to content

Latest commit

 

History

History
66 lines (41 loc) · 4.21 KB

DAY-3.md

File metadata and controls

66 lines (41 loc) · 4.21 KB

DAY-3 | Apache Tomcat Hands-On

Apache Tomcat, often referred to simply as Tomcat, is an open-source web server and servlet container developed by the Apache Software Foundation. It is one of the most popular Java-based web application servers used for deploying and running Java servlets and JavaServer Pages (JSP).

Tomcat is designed to be lightweight and easy to use, making it a popular choice for developers and organizations looking to deploy Java web applications. Tomcat is widely used in both development and production environments and is compatible with various operating systems, including Windows, Linux, and macOS.

Click Below to watch the video Tutorial

Watch the video

Real World Scenario

One real-world scenario where Apache Tomcat is commonly used is in the deployment of enterprise web applications. Let's consider an example of an e-commerce website.

  • Development: The development team builds a Java-based e-commerce web application using servlets and JSPs. They use Apache Tomcat as the target runtime environment during development, allowing them to test and debug the application locally.

  • Testing: Testers can deploy the application on a dedicated Tomcat server or use a shared Tomcat instance for testing purposes.

  • Staging: After successful testing, the application moves to the staging environment, where it is deployed on a dedicated Tomcat server that closely resembles the production environment.

  • Production Deployment: Once the application passes all the required tests and validations, it is ready for deployment to the production environment. In the production setup, Tomcat is configured to handle the incoming web requests and serve the dynamic content generated by the application.

  • Scalability and Load Balancing: As the e-commerce website gains popularity and experiences increased traffic, the need for scalability arises. Tomcat's clustering and load balancing capabilities come into play. Multiple Tomcat instances are set up and configured in a cluster, and a load balancer is placed in front of them. The load balancer distributes incoming requests across the cluster, ensuring high availability, fault tolerance, and efficient utilization of server resources.

  • Monitoring and Management: Tomcat's built-in monitoring and management features are utilized to monitor the performance and health of the production environment.

  • Security: Tomcat provides various security mechanisms to protect the e-commerce website. It supports SSL/TLS encryption to secure data transmission between clients and the server.

In this real-world scenario, Apache Tomcat serves as the underlying web server and servlet container, providing a reliable and scalable platform for hosting the e-commerce website. Its features and capabilities ensure efficient deployment, management, and secure operation of the Java-based web application throughout its lifecycle.

Commands To Setup:

##################----INSTALL TOMCAT----##################
cd /opt
sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz
sudo tar -xvf apache-tomcat-9.0.65.tar.gz

cd /opt/apache-tomcat-9.0.65/conf
sudo vi tomcat-users.xml
# ---add-below-line at the end (2nd-last line)----
# <user username="admin" password="admin1234" roles="admin-gui, manager-gui"/>

sudo ln -s /opt/apache-tomcat-9.0.65/bin/startup.sh /usr/bin/startTomcat
sudo ln -s /opt/apache-tomcat-9.0.65/bin/shutdown.sh /usr/bin/stopTomcat

sudo vi /opt/apache-tomcat-9.0.65/webapps/manager/META-INF/context.xml

comment:
<!-- Valve className="org.apache.catalina.valves.RemoteAddrValve"
  allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

sudo vi /opt/apache-tomcat-9.0.65/webapps/host-manager/META-INF/context.xml

comment:
<!-- Valve className="org.apache.catalina.valves.RemoteAddrValve"
  allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

sudo stopTomcat
sudo startTomcat

sudo cp target/*.war /opt/apache-tomcat-9.0.65/webapps/

After copying the Artifact in webapps folder we can see the deployed application

alt text