Tomcat webserver tutorial
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:
Webpages (both html and jsp) will be served from the examples directory in the path: xampp/tomcat/webapps/examples.
When installing Xampp, install the server control console:
We will start the Tomcat web server. We then open a browser and type:
The page: index.html from the examples directory (confirming the correct installation of the Tomcat web server) will be displayed.
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.
We will put this page (test.jsp) into the examples directory (where the web pages are served), and we will type in the browser:
The current date and time will be displayed as in the following figure: