Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
13.3 Setting Bean Properties
303
Associating All Properties with Input Parameters
Associating a property with an input parameter saves you the bother of per 
forming conversions for many of the simple built in types. JSP lets you take
the process one step further by associating all properties with identically
named input parameters. All you have to do is to supply 
"*"
 for the 
prop 
erty
 parameter. So, for example, all three of the 
jsp:setProperty
 state 
ments of Listing 13.5 can be replaced by the following simple line. Listing
13.6 shows the complete page.
Although this approach is simple, four small warnings are in order. First, as
with individually associated properties, no action is taken when an input
parameter is missing. In particular, the system does not supply 
null
 as the
property value. Second, the JSWDK and the Java Web Server both fail for
conversions to properties that expect 
double
 values. Third, automatic type
conversion does not guard against illegal values as effectively as does manual
type conversion. So you might consider error pages (see Sections 11.9 and
11.10) when using automatic type conversion. Fourth, since both property
names and input parameters are case sensitive, the property name and input
parameter must match exactly. 
Core Warning
In order for all properties to be associated with input parameters, the 
property names must match the parameter names exactly, including case.
Listing 13.6 SaleEntry3.jsp 
Using jsp:setProperty
      HREF="JSP Styles.css"
      TYPE="text/css">
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved