How Tomcat Works

Running the Application

To run the application on Windows, type the following command from the working directory:

java -classpath ./lib/servlet.jar;./ ex02.pyrmont.HttpServer1

In Linux, you use a colon to separate two libraries:

java -classpath ./lib/servlet.jar:./ ex02.pyrmont.HttpServer1

To test the application, type the following in your URL or Address box of your browser:

http://localhost:8080/index.html

or

http://localhost:8080/servlet/PrimitiveServlet

When invoking PrimitiveServlet, you will see the following text in your browser: Hello. Roses are red.

Note that you cannot see the second string Violets are blue, because only the first string is flushed to the browser. We will fix this problem in Chapter 3, though.