SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 561 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

do
This form is very different from earlier ones in this chapter. Instead of using the standard
HTML FORM tag, we import and use the Struts html:form tag. This tag automatically
generates the Web application prefix, appends the .do suffix, and sets the
default request method to POST. Here, we use
<%@ taglib uri="http://struts.apache.org/tags-html"
prefix="html" %>

...

to get something equivalent to

...

Even more important, html:form causes the system to find or instantiate a bean
corresponding to the action. Because the action of html:form matches the
path attribute of the action declaration in struts-config.xml, a bean is automatically
created when the input page is accessed. The system determines the type of
bean to create by looking at the name that goes with the action, and finding the
form-bean with the same name. In this case, the bean is a ContactFormBean.
Next, the bean properties are used for the form fields. After declaring the form
and associating it with a bean, we use html:text to build input elements whose
NAME and VALUE are taken from the names and values of the form bean??™s properties.
In essence, the code fragment
First name:
results in something similar to
class="coreservlets.


Pages:
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573