Java Servlet Programming, 2nd Edition > 4. Retrieving Information |
Chapter 4. Retrieving InformationTo build a successful web application, you often need to know a lot about the environment in which it is running. You may need to find out about the server that is executing your servlets or the specifics of the client that is sending requests. And no matter what kind of environment the application is running in, you most certainly need information about the requests that the application is handling. A number of methods provide servlets access to this information. For the most part, each method returns one specific result. Compared this to the way environment variables are used to pass a CGI program its information, the servlet approach has several advantages:
If you're coming to servlets from CGI, Table 4-1 is a "cheat sheet" you can use for your migration. It lists each CGI environment variable and the corresponding HTTP servlet method.
In the rest of this chapter, we'll see how and when to use these methods and many other methods that have no CGI counterparts. Along the way, we'll put the methods to use in some real servlets.
|