O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

<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...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required