O'Reilly logo

J2EE™ Tutorial, The by Beth Stearns, Monica Pawlan, Eric Jendrock, Kim Haase, Dale Green, Stephanie Bodoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Service Methods

The service provided by a servlet is implemented in the service method of a GenericServlet, the doMethod methods (where Method can take the value Get, Delete, Options, Post, Put, Trace) of an HttpServlet,orany other protocol-specific methods defined by a class that implements the Servlet interface. In the rest of this chapter, the term service method will be used for any method in a servlet class that provides a service to a client.

The general pattern for a service method is to extract information from the request, access external resources, and then populate the response based on that information.

For HTTP servlets, the correct procedure for populating the response is to first fill in the response headers, then retrieve ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required