Thread: JspParseException invalid Attribute


Permlink Replies: 2 - Pages: 1 - Last Post: May 2, 2006 1:24 AM Last Post By: user506674
user506674

Posts: 2
Registered: 04/28/06
JspParseException invalid Attribute
Posted: Apr 28, 2006 5:32 AM
Click to report abuse...   Click to reply to this thread Reply
hello,

I'm using Oracle Application Server 10.1.2.0.2....
and i got a 500 Internal Server Error for a jsp

Part of the source code looks like following:

%><c:otherwise><%

%><spfparam:register name="topic" value="catator" redirect="<%= !"catator".equals(request.getParameter("topic")) %>" /><%
%><jsp:forward page="catator/showCatator.jsp" /><%

%></c:otherwise><%

I have declared the standard tag library and my custom tag library 'spfparam' at the beginning of the jsp-file. I have a problem with the tag spfparam:register. It gets 3 parameters (name, value and redirect). The problem occurs on the redirect attribute, as the OracleJSP compiler outputs following exception:

OracleJSP: oracle.jsp.parse.JspParseException: /sfs/local/topic/showDispatcher.jsp: Line # 351, %><spfparam:register name="topic" value="catator" redirect="<%= !"catator".equals(request.getParameter("topic")) %>" /><%
Error: Attribute: catator".equals(request.getParameter("topic")) is not a valid attribute name

In the tag library descriptor the redirect attribute is marked as rtexprvalue true...
It seems that the compiler thinks that catator will be another attribute of the tag.
I've tested it also with Tomcat 4.1.31. and there is no problem with the code.

Does anyone have a solution for this problem ??

Thx in advance

qiang.lin@oracl...

Posts: 1,113
Registered: 09/20/03
Re: JspParseException invalid Attribute
Posted: Apr 29, 2006 11:20 AM   in response to: user506674 in response to: user506674
Click to report abuse...   Click to reply to this thread Reply
OracleJSP: oracle.jsp.parse.JspParseException: /sfs/local/topic/showDispatcher.jsp:
Line # 351, --%><spfparam:register name="topic" value="catator"
redirect="<%= !"catator".equals(request.getParameter("topic")) %>" /><%--
Error: Attribute: catator".equals(request.getParameter("topic")) is not a valid attribute name

Can you try
  redirect='<%= !"catator".equals(request.getParameter("topic")) %>'
Note the single quotes here.

The error message, which talks about "not a valid attribute name", is indeed not enlightening. The issue is about the correct quoting convention. Excerpt from the JSP 1.2 specification,

--------begin quoting the spec
Quoting in Attributes
 A ' is quoted as \'. This is required within a single quote-delimited attribute
value.
 A " is quoted as \". This is required within a double quote-delimited attribute
value.
Examples
The following line shows an illegal attribute values.
• <mytags:tag value="<%= "hi!" %>" />

end quoting the spec

The same specification are also in JSP spec 2.0, which is implemented in oc4j 10.1.3 and JSP spec 2.1, which will be released soon. So it is certainly not a defect of oc4j to throw parsing exception for your code.

I've tested it also with Tomcat 4.1.31. and there is no problem with the code.

Ok. So Tomcat is tolerant to that illegal usage. As I tested, the recent glassfish is also tolerant to that illegal usage. However, I doubt whether that behavior is indeed conforming to the spec. Maybe a bug can be filed against them.

Anyway, it is better to write strictly according to the spec instead of relying on the fault tolerance of any particular server. Your code will be more portable across j2ee servers then.

Now please tell me this is helpful. :)
user506674

Posts: 2
Registered: 04/28/06
Re: JspParseException invalid Attribute
Posted: May 2, 2006 1:24 AM   in response to: qiang.lin@oracl... in response to: qiang.lin@oracl...
Click to report abuse...   Click to reply to this thread Reply
Hello,

your hint was very helpful, and you have right in any way, writing
code strictly to the spec is always better :-)

greets
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums