Java Servlets   «Prev  Next»

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
  1. generate dynamic pages,
  2. read from and write to databases,
  3. 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
  1. HTML forms,
  2. client-side Java applets, and
  3. 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:
  1. Understand the Servlet API
  2. Set up and configure servers with servlet functionality
  3. Understand the Java servlet program structure, packages, and syntax
  4. Build servlets that generate dynamic Web pages
  5. Build servlets that process data from an HTML form and from a Java applet
  6. Build servlets that enable users to manipulate records in a database via an HTML form
  7. Generate email messages from a servlet based on information submitted from an HTML form
  8. Understand and address servlet security issues such as HTTP authentication and digital certificates
  9. Chain servlets
  10. 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:
  1. 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
    
  2. 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".
  3. 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.23jakarta.servlet-api-5.0.jarjakarta.jsp-api-3.0.jaropenjdk version "17.0.6"
7.0 3.02.2 1.6
6.0 2.52.1 1.5
5.5 2.4 2.01.4
4.12.31.2 1.3
3.0 2.21.11.1

In the next lesson, the course prerequisites will be discussed.