Servlets

The JSP specification is based on the Java servlet specification. In fact, JSP pages are often combined with servlets in the same application. So to use JSP effectively, it’s important to understand the similarities and the concepts that apply to both technologies. In this section, we first take a brief look at what a servlet is, and then discuss the concepts shared by servlets and JSP pages. In Chapter 3, we’ll take a closer look at how JSP pages are actually turned into servlets automatically.

If you’re already familiar with servlets, this is old news. You can safely skip the rest of this chapter. If you’re not familiar with programming, don’t worry about the details. The important thing is that you get familiar with the concepts described in the remainder of this chapter.

Advantages Over Other Server-Side Technologies

In simple terms, a servlet is a piece of code that adds new functionality to a server (typically a web server), just like CGI and proprietary server extensions such as NSAPI and ISAPI. But compared to other technologies, servlets have a number of advantages:

Platform and vendor independence

Servlets are supported by all the major web servers and application servers, so a servlet-based solution doesn’t tie you to one specific vendor. And because servlets are written in the Java programming language, they can be used on any operating system with a Java runtime environment.

Integration

Servlets are developed in Java and can therefore take advantage of all the other ...

Get Java Server 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.