You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cynthia Hertzer <he...@metnet.navy.mil> on 2002/08/23 02:40:01 UTC

Using RTEs in attribute values in XML JSPs

Hello,
I've been reading archived struts-user emails but haven't been able to 
solve this problem to my satisfaction.

I have a JSP, written using the XML JSP syntax, that outputs XML. I want 
to use a run-time expression (RTE) inside a Struts 1.0.2 <logic:iterate> 
tag, for example:

<!-- %= listitem.getString() % does not get evaulated in this example -->
<logic:iterate id="listitem" name="list" type="foo.struct" scope="request">
  <image xlink:href="%= listitem.getString()%"/>
</logic:iterate>

<!-- Here, listitem.getString() gives the expected value from the bean, 
but I can't use <jsp:expression>
to assign an attribute's value in an XML-syntax JSP without getting the 
error "
The value of attribute "xlink:href" must not contain the '<' character. 
" -->

<logic:iterate id="listitem" name="list" type="foo.struct" scope="request">
  <jsp:expression> listitem.getString() </jsp:expression>   
</logic:iterate>

I hope I am just missing some simple escape sequence, but I've tried 
various ideas and haven't gotten lucky. My workaround is:

<!-- Works, but... Yuk! -->
<logic:iterate id="listitem" name="list" type="foo.struct" scope="request">
  <jsp:scriptlet>
    out.write("&lt;image xlink:href=\"" + listitem.getString() + "\"/&gt;");
  <jsp:scriptlet>
</logic:iterate>

Can anyone tell me a better way? I haven't tried to use a RTE to assign 
outside of the struts iterator. I'd really like to avoid adding any 
other taglibs to my app. if possible. Do I need struts 1.1?

Thanks,
Cindy
-----
Cynthia Hertzer
hertzerc@metnet.navy.mil






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Using RTEs in attribute values in XML JSPs

Posted by "Craig R. McClanahan" <cr...@apache.org>.
My bet is that you'll find the traditional JSP syntax more palatable for
hand authored pages -- even those that ultimately render XML content.  The
XML syntax is designed to be consumed by tools, and isn't really very
human friendly.

Craig


On Thu, 22 Aug 2002, Cynthia Hertzer wrote:

> Date: Thu, 22 Aug 2002 17:40:01 -0700
> From: Cynthia Hertzer <he...@metnet.navy.mil>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: Using RTEs in attribute values in XML JSPs
>
> Hello,
> I've been reading archived struts-user emails but haven't been able to
> solve this problem to my satisfaction.
>
> I have a JSP, written using the XML JSP syntax, that outputs XML. I want
> to use a run-time expression (RTE) inside a Struts 1.0.2 <logic:iterate>
> tag, for example:
>
> <!-- %= listitem.getString() % does not get evaulated in this example -->
> <logic:iterate id="listitem" name="list" type="foo.struct" scope="request">
>   <image xlink:href="%= listitem.getString()%"/>
> </logic:iterate>
>
> <!-- Here, listitem.getString() gives the expected value from the bean,
> but I can't use <jsp:expression>
> to assign an attribute's value in an XML-syntax JSP without getting the
> error "
> The value of attribute "xlink:href" must not contain the '<' character.
> " -->
>
> <logic:iterate id="listitem" name="list" type="foo.struct" scope="request">
>   <jsp:expression> listitem.getString() </jsp:expression>
> </logic:iterate>
>
> I hope I am just missing some simple escape sequence, but I've tried
> various ideas and haven't gotten lucky. My workaround is:
>
> <!-- Works, but... Yuk! -->
> <logic:iterate id="listitem" name="list" type="foo.struct" scope="request">
>   <jsp:scriptlet>
>     out.write("&lt;image xlink:href=\"" + listitem.getString() + "\"/&gt;");
>   <jsp:scriptlet>
> </logic:iterate>
>
> Can anyone tell me a better way? I haven't tried to use a RTE to assign
> outside of the struts iterator. I'd really like to avoid adding any
> other taglibs to my app. if possible. Do I need struts 1.1?
>
> Thanks,
> Cindy
> -----
> Cynthia Hertzer
> hertzerc@metnet.navy.mil
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>