Skip to Content
Head First Servlets and JSP, 2nd Edition
book

Head First Servlets and JSP, 2nd Edition

by Bryan Basham, Kathy Sierra, Bert Bates
March 2008
Intermediate to advanced
911 pages
20h 31m
English
O'Reilly Media, Inc.
Content preview from Head First Servlets and JSP, 2nd Edition

<rtexprvalue> is NOT just for EL expressions

You can use three kinds of expressions for the value of an attribute (or tag body) that allows runtime expressions.

  1. EL expressions

    <mine:advice user="${userName}" />
  2. Scripting expressions

    image with no caption
  3. <jsp:attribute> standard actions

    <mine:advice>
       <jsp:attribute name="user">${userName}</jsp:attribute>
    </mine:advice>

    Note

    What is this?? I thought this tag didn’t have a body...

Note

<jsp:attribute> lets you put attributes in the BODY of a tag, even when the tag body is explicitly declared “empty” in the TLD!!

The <jsp:attribute> is simply an alternate way to define attributes to a tag. The key point is, there must be only ONE <jsp:attribute> for EACH attribute in the enclosing tag. So if you have a tag that normally takes three attributes IN the tag (as opposed to in the body), then inside the body you’ll now have three <jsp:attribute> tags, one for each attribute. Also notice that the <jsp:attribute> has an attribute of its own, name, where you specify the name of the outer tag’s attribute for which you’re setting a value. There’s a little more about this on the next page...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First Java, 2nd Edition

Head First Java, 2nd Edition

Kathy Sierra, Bert Bates
Head First Java, 3rd Edition

Head First Java, 3rd Edition

Kathy Sierra, Bert Bates, Trisha Gee
Learning Java, 6th Edition

Learning Java, 6th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 9780596516680Errata PageSupplemental Content