Lesson 1
Java Servlets Intro
This course teaches you how to deliver server-side interactivity on almost any server platform, using the Java programming language and just a few extra classes from a readily available library. Servlets are little snippets of code that run on the computer that is serving out your Web pages. You can use them to
- generate dynamic pages,
- read from and write to databases,
- maintain a consistent user state as your user moves from page to page.
This course builds on your knowledge of the Java language and the Java 2 Platform. You will start building servlets right away; beginning with generating a simple page, then learning how to get your servlet to interact with
- HTML forms,
- client-side Java applets, and
- databases.
Furthermore, you will see how servlet chaining can add tremendous power to your site very simply.
Many developers are considering servlets as an alternative to SSI, CGI, ASP, and other server-side technologies. Servlets are a stand alone technology and you do not need to know any other server-side technology to benefit from this material.
Course Objectives
After completing the course, you will be able to:
- Understand the Servlet API
- Set up and configure servers with servlet functionality
- Understand the Java servlet program structure, packages, and syntax
- Build servlets that generate dynamic Web pages
- Build servlets that process data from an HTML form and from a Java applet
- Build servlets that enable users to manipulate records in a database via an HTML form
- Generate email messages from a servlet based on information submitted from an HTML form
- Understand and address servlet security issues such as HTTP authentication and digital certificates
- Chain servlets
- Write servlets that communicate with other Java servers
Determine the version of Tomcat Running
There are several ways to determine the Tomcat version running on your Ubuntu server. Here are three options:
- Using the `version.sh` script: This is the recommended method. Most Tomcat installations include a script named `version.sh` in the `bin` directory. You can execute this script to get the version information:
sudo su -
cd /path/to/tomcat/bin
./version.sh
- Checking the Tomcat web interface:
If Tomcat is already running, you can access the web interface and find the version information there. The default location is usually:
http://localhost:8080/tomcat/about.jsp
However, this might be different depending on your configuration. Look for a page mentioning "Apache Tomcat" or "Tomcat version".
- Checking the package manager:
If you installed Tomcat using the Ubuntu package manager, you can use the `dpkg` command to find the installed version:
sudo dpkg -l tomcat*
This will list all packages related to Tomcat, including the version number.
Additional notes:
- Replace `/path/to/tomcat/bin` with the actual path to your Tomcat installation directory.
- You might need to run the commands with `sudo` privileges depending on your user permissions.
- If you have multiple Tomcat versions installed, these methods will only show the version of the currently running instance.
Tomcat Server, Servlet API, JSP API Architecture
Command to execute at the prompt to determine which version of Tomcat you are running.
sudo find / -name version.sh
/opt/apache-tomcat-10.0.23/bin/version.sh
Table 1-1. Tomcat Versions and Supported API and JDK Versions
Apache Tomcat |
Servlet API |
JSP API |
JDK |
10.0.23 | jakarta.servlet-api-5.0.jar | jakarta.jsp-api-3.0.jar | openjdk version "17.0.6" |
7.0 | 3.0 | 2.2 | 1.6 |
6.0 | 2.5 | 2.1 | 1.5 |
5.5 | 2.4 | 2.0 | 1.4 |
4.1 | 2.3 | 1.2 | 1.3 |
3.0 | 2.2 | 1.1 | 1.1 |
In the next lesson, the course prerequisites will be discussed.