Home > Articles

  • Print
  • + Share This
This chapter is from the book

Summary

In this chapter the Servlet API was introduced, and focus was placed specifically on Servlets. Servlets are the fundamental building block of server-side Java. A Servlet is highly scalable and easily outperforms traditional CGI by means of a simple three-phase life cycle: initialization, service, and destruction. Commonly, the term Servlets actually refers to HTTP Servlets used on the World Wide Web. The HttpServlet class is designed especially for this user and greatly simplifies server-side Java support for HTTP.

The basics of the Servlet API consist of objects that represent a client's request, HttpServletRequest, the server's response, HttpServletResponse, a session for connecting separate requests, HttpSession, and an entire Web Application, ServletContext. Each of these objects provides a complete set of methods for accessing and manipulating related information. These objects also introduce two new scopes for Servlet developers to use: request and application. Binding an object to these various scopes allows a Servlet developer to share an object between multiple Servlets and requests for extended periods of time. What was only briefly mentioned is that a third, commonly used scope, session, is also available. Session scope introduces several issues which merit a complete chapter's worth of information. Chapter 9 fully explains session scope and the issues relating to it.

Overall, this chapter is a reference to creating and using Servlets. Chapter 3 continues discussion of Servlets by introducing a complementary technology: JavaServer Pages.

  • + Share This
  • 🔖 Save To Your Account