For example, an e-commerce site could use a servlet tobuild a Web page that lists the current price and availability of each saleitem. The Web page uses information from corporate databases or otherserver-side sources. Forexample, a weather report or news headlines site might build the pagesdynamically, perhaps returning a previously built page if that page is still upto date. The Web page is derived from data that changes frequently. In particular, it is quite common to build a user-specific page based on acookie value. Either kind of input can be used to build the outputpage. Just remember that the usersubmits two kinds of data: explicit (i.e., HTML form data) and implicit (i.e.,HTTP request headers). For instance,the results page from search engines and order-confirmation pages at onlinestores are specific to particular user requests. The Web page is based on data sent by the client. There are a number of reasons why Web pages need to be built on-the-flylike this: In many cases, however, astatic result is not sufficient, and a page needs to be generated for eachrequest. Many client requests can be satisfied by prebuilt documents, and the serverwould handle these requests without invoking servlets. Sending HTTP response data involves telling thebrowser or other client what type of document is being returned (e.g., HTML),setting cookies and caching parameters, and other such tasks. Both varieties are criticalto effective development. But, there are really two varieties of data sent: the documentitself and the behind-the-scenes HTTP information. Figure 2≡ shows asingle arrow going from the Web middle layer (the servlet or JSP page) to theclient. Thisdocument can be sent in a variety of formats, including text (HTML), binary (GIFimages), or even a compressed format like gzip that is layered on top of someother underlying format. Send the explicit data (i.e., the document) to the client. You need the Web middle layer toextract the incoming data from the HTTP stream, talk to the application, andembed the results inside a document. The sameargument applies to most other applications. But your database probably doesn't speak HTTP or return results inHTML, so the Web browser can't talk directly to the database. Your real data may be in a relational database.Fine. This process may require talking to adatabase, executing an RMI or CORBA call, invoking a legacy application, orcomputing the response directly. The HTTP information includes cookies, media types and compressionschemes the browser understands, and so forth. Both varieties are critical to effectivedevelopment. and thebehind-the-scenes HTTP information. Figure 2≡ shows a single arrow going from the client to the Web server (the layerwhere servlets and JSP execute), but there are really two varieties ofdata: the explicit data the end user enters in a form 2. Read the implicit HTTP request data sent by the browser. However, the data could alsocome from an applet or a custom HTTP client program. The end user normallyenters this data in an HTML form on a Web page. Read the explicit data sent by the client. Their job is to perform thefollowing tasks, as illustrated in Figure 2≡. They are programs that run on a Web server, acting as a middlelayer between a request coming from a Web browser or other HTTP client anddatabases or applications on the HTTP server. Servlets are Java technology's answer to Common Gateway Interface (CGI)programming. The servlet equivalent of the standard CGI variables HTTP 1.1 request headers, response headers, and status codes The basic servlet structure and life cycle The advantages of servlets over competing technologies