You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Andrew Jaquith <an...@me.com> on 2008/10/04 15:22:38 UTC

Question about JSP tag usage

Question:

What are the rules for JSP tag usage inside of another tag?

Clearly, this (non-embedded) version is legal:

&lt;foo value="bar"&rt;

...and so is this version, where the attribute value is determined by  
evaluating a nested JSP tag:

&lt;foo value="&lt;c:out value='${i.version}'/&gt;"&gt;

...but what about generating the attribute NAME based on a nested JSP  
tag? Example:

&lt;foo &lt;c:if test="${i.version ==  
olddiff}"&gt;selected="selected"&lt;/c:if&gt; &gt;&lt;c:out value="$ 
{i.version}"/&gt;&lt;/option&gt;

... where here, a c:if element determines whether the "selected"  
attribute appears.

We have something like this in DiffTab.jsp, and it seems like it  
shouldn't work. But it does. Why? Is this valid syntax or is it just  
that the JSP compiler is more lenient?

Andrew

Re: Question about JSP tag usage

Posted by Andrew Jaquith <an...@me.com>.
Hrmmmmm. I guess that means my JSP migration tool for 2.x --> 3.x will  
need a little more work done on it, then. :)

On Oct 4, 2008, at 11:37 AM, Janne Jalkanen wrote:

>> &lt;foo &lt;c:if test="${i.version ==  
>> olddiff}"&gt;selected="selected"&lt;/c:if&gt; &gt;&lt;c:out value="$ 
>> {i.version}"/&gt;&lt;/option&gt;
>>
>> ... where here, a c:if element determines whether the "selected"  
>> attribute appears.
>>
>> We have something like this in DiffTab.jsp, and it seems like it  
>> shouldn't work. But it does. Why? Is this valid syntax or is it  
>> just that the JSP compiler is more lenient?
>
> I do believe it is a valid syntax if the JSPs are not in XML  
> "mode".  JSP pages are not valid XML, unless explictly stated so.
>
> /Janne


Re: Question about JSP tag usage

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
> &lt;foo &lt;c:if test="${i.version ==  
> olddiff}"&gt;selected="selected"&lt;/c:if&gt; &gt;&lt;c:out value="$ 
> {i.version}"/&gt;&lt;/option&gt;
>
> ... where here, a c:if element determines whether the "selected"  
> attribute appears.
>
> We have something like this in DiffTab.jsp, and it seems like it  
> shouldn't work. But it does. Why? Is this valid syntax or is it  
> just that the JSP compiler is more lenient?

I do believe it is a valid syntax if the JSPs are not in XML "mode".   
JSP pages are not valid XML, unless explictly stated so.

/Janne