Appendix B. JSPs and Servlets

This appendix is meant to be a kind of bridge from your skills as a system administrator, which probably include a familiarity with a variety of scripting languages, to give you some familiarity with the Java development side of Tomcat. Since Tomcat specializes in running servlets and JSPs, we discuss what these are in a bit more detail. First, though, we review a variety of network software architectures, so you have a better idea of where servlets and JSPs fit into the big picture of network software development.

Here are four general Java-centric approaches to networked application development. Since almost all web applications need access to a backend database, we also say a few words about how the Java code accesses the database.

Web application displays an applet, and the applet uses JDBC to connect to a database

—Slow; browser incompatibilities

Download application using Java Web Start; application uses JDBC

—Avoids browser problem; performance can be slow due to lack of caching

Web application sends pure HTML and uses servlets and JSPs

—Servlets use JDBC; JSPs, if necessary, use the Java Standard Template Library (JSTL)

—Closest to use of mod_perl, PHP, or CGI

—Good general approach

Web application uses servlets, and servlets use EJBs to access database

—Claimed to be a good “enterprise"-scale approach (J2EE-style)

Briefly, a servlet is a Java program designed to run in a servlet container (we hope you didn’t catch that circular definition), and a JSP ...

Get Tomcat: The Definitive Guide 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.