Review: Using JavaBeans
Components with JSP
Benefits of jsp:useBean
Hides the Java programming language syntax
Makes it easier to associate request parameters with
objects (bean properties)
Simplifies sharing objects among multiple requests or
servlets/JSPs
jsp:useBean
Creates or accesses a bean
jsp:getProperty
Puts bean property (i.e. getXxx call) into output
jsp:setProperty
Sets bean property (i.e. passes value to setXxx)
119
JSP
www.corewebprogramming.com
Review: Creating Custom
JSP Tag Libraries
For each custom tag, you need
A tag handler class (usually extending
TagSupport or BodyTagSupport)
An entry in a Tag Library Descriptor file
A JSP file that imports library, specifies prefix,
and uses tags
Simple tags
Generate output in doStartTag, return SKIP_BODY
Attributes
Define setAttributeName method. Update TLD file
Body content
doStartTag returns EVAL_BODY_INCLUDE
Add doEndTag method
120
JSP
www.corewebprogramming.com
60