Hosting with Apache Tomcat

tomcat

31 Aug '24

Apache Tomcat is a free and open-source Java web application server (servlet container). It hosts Java-based web applications, implementing Jakarta Servlet, Jakarta Servlet Pages (JSP), Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations and Jakarta Authentication specifications. These 'Jakarta's refer to the Jakarta Enterprise Edition (formerly Java EE), which is a set of specifications that extends the Java Standard Edition (SE) with enterprise-grade features. They were renamed from Java to 'Jakarta' after Oracle transferred Java EE to the Eclipse Foundation. Apache Tomcat is also fully capable of serving static web pages, although this underutilises its robust features. The official documentation for Apache Tomcat can be found at https://tomcat.apache.org/.

In this video tutorial, we will set up Apache Tomcat to serve websites locally. We will start with serving static html files. We will also do justice to the capabilities of Apache Tomcat by serving dynamic JSP files.


In the video, Apache Tomcat was downloaded and configured to serve the website manually. In a more advanced Java web framework like Spring Boot, Apache Tomcat is downloaded automatically and configured automatically by using the 'spring-boot-starter-web' library, which can be specified in Maven's pom.xml file or from the Spring Initializr.

In a traditional setup, as shown in the video, Apache Tomcat is manually downloaded, installed, and configured to serve web applications. This involves setting up the server environment, deploying the application, and managing the server configuration files.

However, in a modern Java web framework like Spring Boot, these steps are greatly simplified. Spring Boot automatically handles the downloading and configuration of Apache Tomcat through its embedded server mechanism. By including the 'spring-boot-starter-web dependency' in the pom.xml file, Tomcat is automatically embedded within the application, which allows the application to run independently as a self-contained unit.

The websites have all been hosted locally at port 8080. The port number can be changed at config.xml in the config folder. Hosting them locally is of little use as they are not accessible publicly. This is where we transition to hosting Apache Tomcat in the cloud, with various offerings provided by Amazon Web Services (AWS), Google Cloud Platform (GCP) and Microsoft Azure. Well, that will be worthy of an article of its own, isn't it? Till then, hope you have learnt a thing or two about Apache Tomcat and the history of Jakarta EE.