A JSP is just another servlet, and like HTTP servlets, a JSP is a server-side Web component that can be used to generate dynamic Web pages.
The fundamental difference between servlets and JSPs is
Servlets generate HTML from Java code.
JSPs embed Java code in static HTML.
To illustrate this difference, Listings 13.1 and 13.2 are the same Web page coded as a servlet and as a JSP, respectively. Each Web page simply reads a parameter called name from the HTTP request and creates an HTML page displaying the value of the name parameter. Listing 13.1 shows the servlet, and Listing 13.2 shows the JSP.
1: import java.io.*; 2: import javax.servlet.*; 3: import javax.servlet.http.*; 4: 5: public ...