2008/9/19 Mark Thomas <[EMAIL PROTECTED]>:
> Mark Thomas wrote:
>> Konstantin Kolinko wrote:
>>> In JSP 2.1 spec there is chapter
>>> JSP.1.6 Quoting and Escape Conventions
>>> - see "Quoting in Attributes" part there.
>>>
>>> Thus, IMHO, ${\'string literal\'} will be valid if used as the value for
>>> an attribute of custom tag.
> I've looked at this again and I don't believe this is valid, even if used
> as the value for a tag attribute.
>
>>> The example from the spec
>>> <x:tag value="<%= \"Joe said 'hello'\" %>"/>
>>> becomes
>>> <x:tag value="${ \"Joe said 'hello'\" }"/>
> I think this should be:
> <x:tag value="${"Joe said 'hello'"}"/>
>
> My reasoning is as follows (quoting selectively from JSP.1.3.10)
>
> This section presents a simple EBNF grammar for the JSP syntax. The grammar
> is intended to provide a concise syntax overview and to resolve any syntax
> ambiguities present in this specification. Other sections may apply further
> restrictions to this syntax, for example to restrict what represents a
> valid attribute value for a page directive. In all other cases the grammar
> takes precedence in resolving syntax questions.
>
> So, starting with Attribute:
>
> Attribute ::= Name Eq
> (skipped...)
>

Mark,

I tend to agree with your reading of the EBNF grammar there, but I think that
the grammar is wrong.

The first sentence of "Quoting in Attributes" part in JSP.1.6 says:
"Quotation is done consistently regardless of whether the attribute value is a
literal or a request-time attribute expression."

<x:tag value="${"Joe said 'hello'"}"/>
is not a consistent quoting, IMHO.

Also, from historical perspective, do you think that quoting rules has changed
between JSP 1.2 and 2.0?

JSP 1.2:
IIRC (though only from theory/sources, too little practical experience with
JSP 1.2), in JSTL 1.0 those expressions are just plain strings, passed to
the tags "as is" for evaluation. So, how those were quoted in tag attributes?


JSP 2.0:
Reading the JSP 2.0 specification, the wording in JSP.1.6 and EBNF
expressions in JSP.1.3.10 are exactly the same is in JSP 2.1 spec,
with the exception that the EL language is defined in the same document.

So, the error in EBNF is also present in JSP 2.0.

Implementation of JSP 2.0 can be tested with Tomcat 5.5, and the following:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:out value="${ \"Joe said 'hello'\" }" />

prints the string in TC 5.5.25, and the expression without the slashes produces
error 500 ("equal symbol expected") at compile time. I do not have "strict
compliance" configured, if that matters.

I also thought, how the error in the EBNF grammar could be corrected, but
the most simple way IMHO would be to explain the issue in a comment, or
replace the reference to EL grammar (inclusion of it) with a vc: validity
constraint (JSP.1.3.10.2),
rather than to try to express it all as pure EBNF productions.

There are a lot of comments before the grammar.


Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to