Packaging Java Server Pages and Servlets

Servlets and Java Server Pages have their own special type of JAR file for deployment. This JAR file is called a WAR file (short for Web Archive).

When you create a WAR file, you must include a web.xml file that describes the application. Usually, you will at least need descriptions of the various servlets in your application. Listing 21.4 shows a crude servlet that calls a Java Server Page.

Code Listing 21.4. Source Code for ExampleWARServlet.java
 package usingjsp.warexample; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class ExampleWARServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException ...

Get Special Edition Using Java™ 2 Enterprise Edition 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.