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 ...
Get J2EE™ Tutorial, The 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.