1.7. Compile and Test Some Simple Servlets

OK, so your environment is all set. At least you think it is. It would be nice to confirm that hypothesis. Following are three tests that help verify this.

Test 1: A Servlet That Does Not Use Packages

The first servlet to try is a basic one: no packages, no utility (helper) classes, just simple HTML output. Rather than writing your own test servlet, you can just grab HelloServlet.java (Listing 1.3) from the book’s source code archive at http://www.moreservlets.com. If you get compilation errors, go back and check your CLASSPATH settings (Section 1.6)—you most likely erred in listing the location of the JAR file that contains the servlet classes (e.g., servlet.jar). Once you compile Hello-Servlet.java ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.