Writing Results Back To The Client; Using Servlet Filters - MACROMEDIA 38000382 - JRun - Mac Getting Started Manual

Getting started guide
Table of Contents

Advertisement

Servlets answer a request by constructing an HTTP response and sending that response
back to the client. Within your servlet, you access the HTTP response to write
information within the response that is sent back to the client.
You can access HTTP response information in the following ways:
In a Java Servlet, use the
defines methods for accessing the information stored within the response.
In a JSP, use the implicit JSP object
the response object as you can with the
object.
The HTTP response includes an output stream for sending results back to the client.

Writing results back to the client

With servlets, you can return dynamic content to the requesting client. That output is
generated based on information passed to the servlet or on information that the servlet
calculates. For example, a servlet can use a passed form attribute (accessed using the
request object) to return formatted database data. Alternatively, if the application has a
method of maintaining user preferences, the servlet might set the display color of the
browser based on stored preference information.
You return information through the HTTP response, in the following ways:
Servlets use the
ServletOutputStream
methods, which let you write to the output stream.
JSPs use the implicit JSP object
print

Using servlet filters

The Servlet 2.3 specification introduces servlet filters, which give you access to the
HTTP request and response objects for pre- and post-processing. Filters process request
objects before they get to the server, or process response objects after they leave the server
and before they are returned to the client. You can also invoke filters in a chain so that
one filter can pass the request or the response to another in the chain, and so on. You can
use filters to do the following tasks:
Take flow-control logic out of web application components.
Examine and modify the request object before the server receives it from the client.
Examine and modify the response object before the client receives it from the server.
Change the content of the response.
For more information on using filters, see JRun Programmer's Guide.
42
Chapter 4 Using Servlets and JSP
javax.servlet.HttpServletResponse
javax.servlet.HttpServletResponse
interfaces. These interfaces include
methods.
. You can use the same methods with
response
javax.servlet.HttpServletResponse
. The
object also includes
out
out
object, which
object's
or
PrintWriter
and
println
print
and
println

Advertisement

Table of Contents
loading

This manual is also suitable for:

Jrun 4

Table of Contents