Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
13.1 Basic Bean Use
291
attributes: 
name
 (which should match the 
id
 given by 
jsp:useBean
), 
prop 
erty
 (the name of the property to change), and 
value
 (the new value). Sec 
tion 13.3 (Setting Bean Properties) discusses some alternate forms of
jsp:setProperty
 that let you automatically associate a property with a
request parameter. That section also explains how to supply values that are
computed at request time (rather than fixed strings) and discusses the type
conversion conventions that let you supply string values for parameters that
expect numbers, characters, or boolean values. 
An alternative to using the 
jsp:setProperty
 action is to use a scriptlet
that explicitly calls methods on the bean object. For example, given the
book1
 object shown earlier in this section, you could use either of the follow 
ing two forms to modify the 
title
 property:
property="title" 
value="Core Servlets and JavaServer Pages" />
<% book1.setTitle("Core Servlets and JavaServer Pages"); %>
Using 
jsp:setProperty
 has the advantage that it is more accessible to
the nonprogrammer, but direct access to the object lets you perform more
complex operations such as setting the value conditionally or calling methods
other than 
getXxx
 or 
setXxx
 on the object.
Installing Bean Classes
The class specified for the bean must be in the server's regular class path, not
the part reserved for classes that get automatically reloaded when they
change. For example, in the Java Web Server, the main bean class and all the
auxiliary classes it uses should go in the 
install_dir/classes
 directory or
be in a JAR file in 
install_dir/lib
, not in 
install_dir/servlets
. Since
Tomcat and the JSWDK don't support auto reloading servlets, bean classes
can be installed in any of the normal servlet directories. For Tomcat 3.0,
assuming you haven't defined your own Web application, the primary direc 
tory for servlet class files is 
install_dir/webpages/WEB INF/classes
; for
the JSWDK, the default location is
install_dir/webpages/WEB INF/servlets
. With all three servers,
remember that a package name corresponds to a subdirectory. So, for exam 
ple, a bean called 
Fordhook
 that declares  
package lima;
  would typically
be installed in the following locations:
Tomcat 3.0:
install_dir/webpages/WEB INF/classes/lima/Fordhook.cla
ss
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