Java Reference
In-Depth Information
FIGURE 12-26
In some cases, the receiving resource differs, depending on what the user
entered or the result of a database query. If a request to delete a user sends a
valid user ID, then line 158 sets a session attribute, forwardTo, to the delUser.jsp
Java Server Page as the receiving resource. That receiving resource allows the user
to verify the data before deletion.
If an invalid user ID was entered, then line 161 sets the receiving resource
as the HTML page, badUserID.html, which displays an error message. Similar
action is taken on lines 175 and 178 when a request to update a user is received.
For any valid requested action, the servlet will forward the request to the
resource that displays the result to the user, whether a JSP or an HTML page.
To forward a request to another resource, the servlet uses a RequestDispatcher
object. A RequestDispatcher object receives requests and sends them to a given
resource on the server. The servlet container creates the RequestDispatcher
 
Search WWH ::




Custom Search