1.6.5
Redirecting Requests
create/update
Request
Server 
JSP/Servlet
Side
Objects
Client
redirect request
JSP/Servlet
access/update
Response
It is common that the data to be sent to the client varies significantly depending on properties 
of the client that are either directly encoded in the request object or can be discovered based 
on some user/client profile (e.g. stored in a login database). In this case it is very convenient 
to have the initial JSP page determine details about the request, perhaps create and/or update 
some server side objects, and then, if necessary, redirect the request to a different JSP page.
This programming model is supported by the underlying Servlet APIs. The properties of the 
HTTP protocol are such that the redirect cannot be done if the response stream has started 
being sent back to the client; this characteristic makes the description of some common 
situations quite inconvenient. To address this, the JSP specification by default indicates 
buffering on the output stream. The JSP page can redirect the request at any point before 
flushing the output buffer.
Buffering is also very convenient for error page handling, since that is done by redirecting 
the request.
Presentation JSP pages and Front JSP pages
In a slight variation of this model, the front component (a Servlet or a JSP) only creates and/
or updates the server side objects. In this organization, the 
front
 component does no 
presentation at all; instead all presentation is done by a 
presentation
 component. Although 
the front component could be written as a Servlet since it does no presentation, writing it as 
a JSP page enables the use of custom actions for the creation and update of the server side 
objects. The presentation component will almost in all cases be a JSP page, and it will most 
likely access the server side objects through custom actions
1
. 
1. Readers of the original JSP 0.92 draft will recognize the combination  
front component is servlet and presentation 
component is JSP
  as the model 2 mentioned in that draft.
Chapter 1
Overview
32




JSP Web Hosting JavaServer Pages Specifications JSP Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.