10.4 Processing Requests with Action Objects 461
Table 10.3 summarizes the common forward attributes. The default behavior is
to invoke the JSP page with RequestDispatcher.forward, which means that
forwarding occurs within the servlet container, and the URL in the browser will be
the original .do address, not the address of the output JSP page.
Alternatively, if you use redirect="true", the JSP page will be invoked with
response.sendRedirect. As discussed in Chapter 6 of Core Servlets and JavaServer
Pages, Volume 1, a redirect means that a 302 status code and a Location response
header are sent to the browser, and then the browser connects to the URL specified in
the Location header. This means that a redirect results in two round trips from the
browser to the server, and the URL displayed in the browser will reflect the output JSP
page. You only use redirect="true" with session or application scoped data.
Declare the Use of Any Form Beans
The Struts system automatically populates the form bean with the user form data
before sending the request to the Action. We discuss how to declare form beans in
struts-config.xml in Section 10.5 (Handling Request Parameters with Form Beans).
Writing an Action
The execute method of the Action processes the request, applies business and
data-access logic, creates data representing the results (usually stored in the form of
beans), and designates which return condition applies.
Pages:
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513