Tomcat webserver tutorial

<< Prev
Next >>

Introduction

Tomcat is an open-source web server developed by the Apache Software Foundation.

In addition to being able to serve html pages, it can serve pages created with Java technologies: jsp (Java Server Pages) pages. Tomcat also provides support for Java Servlet execution.
A servlet is a code block written in Java, designed to expand server capabilities (to create dynamic web pages in an http server).
Servlet does not run directly on the server, but through a web container.
In Windows, the easiest way to install and configure the Tomcat web server is to install the free Xampp application (like the Apache web server).
The installation directory is called tomcat and shows that in the following figure:


Tomcat

Webpages (both html and jsp) will be served from the examples directory in the path: xampp/tomcat/webapps/examples.


Tomcat

When installing Xampp, install the server control console:


Tomcat

We will start the Tomcat web server. We then open a browser and type:


https://localhost:8080


The page: index.html from the examples directory (confirming the correct installation of the Tomcat web server) will be displayed.


Tomcat

For everything to be fine, we will also test a Java Server Pages (jsp) web page. The jsp web page, besides the html code, also contains Java code blocks, which will be between the tags: <% and %>.
We will create a page called test.jsp to display the current date and time.


Tomcat

We will put this page (test.jsp) into the examples directory (where the web pages are served), and we will type in the browser:


http://localhost:8080/test.jsp


The current date and time will be displayed as in the following figure:


Tomcat
<< Prev
Next >>