Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
542
Appendix A
Servlet and JSP Quick Reference
Optionally Including the Tag Body
Tag handler:
Return
EVAL_BODY_INCLUDE
or
SKIP_BODY
at different times,
depending on value of request time parameter.
Manipulating the Tag Body
Tag handler:
You should extend
BodyTagSupport
, implement
doAfterBody
. Call
getBodyContent
to get
BodyContent
object describing tag body.
BodyContent
has three key methods:
getEnclosingWriter
,
getReader
, and
getString
. Return
SKIP_BODY
from
doAfterBody
.
Including or Manipulating the Tag Body
Multiple Times
Tag handler:
To process body again, return
EVAL_BODY_TAG
from
doAfterBody
. To
finish, return
SKIP_BODY
.
Using Nested Tags
Tag handler:
Nested tags can use
findAncestorWithClass
to find the tag in which
they are nested. Place data in field of enclosing tag.
Tag Library Descriptor:
Declare all tags separately, regardless of nesting structure in real page.
A.15 Integrating Servlets and JSP
Big Picture
Servlet handles initial request, reads parameters, cookies, session
information, etc.
Servlet then does whatever computations and database lookups are
needed.
Servlet then stores data in beans.
Servlet forwards request to one of many possible JSP pages to present
final result.
JSP page extracts needed values from beans.
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