Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
A.13 Using JavaBeans with JSP
539
code="MyApplet.class"
width="475" height="350">
Error: this example requires Java.
The Java Web Server does not properly handle
jsp:fallback
.
A.13 Using JavaBeans with JSP
Basic Requirements for Class to be a Bean
1. Have a zero argument (empty) constructor.
2. Have no public instance variables (fields).
3. Access persistent values through methods called
getXxx
(or
isXxx
) and
setXxx
.
Basic Bean Use
value="value" />
The
value
attribute can take a JSP expression.
Associating Properties with Request Parameters
Individual properties:
name="entry"
property="numItems"
param="numItems" />
Automatic type conversion: for primitive types, performed according
to
valueOf
method of wrapper class.
All properties:
Sharing Beans: The scope Attribute of
jsp:useBean
Examples of sharing beans given in Chapter 15.
page
Default value. Indicates that, in addition to being bound to a local
variable, bean object should be placed in
PageContext
object for
duration of current request.
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
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