You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/01/18 13:42:47 UTC

[Bug 56029] New: Ternary operator doesn't work as expected inside attributes in jspx pages

https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

            Bug ID: 56029
           Summary: Ternary operator doesn't work as expected inside
                    attributes in jspx pages
           Product: Tomcat 7
           Version: 7.0.50
          Hardware: All
                OS: Mac OS X 10.4
            Status: NEW
          Severity: major
          Priority: P2
         Component: Jasper
          Assignee: dev@tomcat.apache.org
          Reporter: michael@simons.ac

The following JSPX file worked upto Tomcat 7.0.47:

<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"    
>
    <jsp:directive.page contentType="text/html; charset=utf-8" 
pageEncoding="UTF-8" />
    <jsp:directive.page session="false" />
    <jsp:output omit-xml-declaration="true" />
    <div>    
        <span id="mainNavNews" class="${currentController eq 'News' ?
'selectedItem' : ''}">foobar</span>    
    </div>    
</jsp:root>

With tomcat 7.0.50 it fails with the following exception:

org.apache.jasper.JasperException: /WEB-INF/views/layouts/mainNavigation.jspx
(line: 10, column: 87) "${currentController eq 'News' ? 'selectedItem' : ''}"
contains invalid expression(s): javax.el.ELException: Failed to parse the
expression [${currentControllereq'News'?'selectedItem':''}]
    at
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
    at
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
    at
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:199)
    at
org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1399)
    at
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:772)
    at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
    at
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:779)
    at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
    at
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:529)
    at org.apache.jasper.compiler.Node$JspRoot.accept(Node.java:564)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
    at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2433)
    at org.apache.jasper.compiler.Node$Root.accept(Node.java:474)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
    at
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1817)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
    at org.apache.jasper.compiler.Compiler.__compile(Compiler.java:373)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
    at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    at
org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

It works when the ternary operation doesn't appear inside an attribute or
instead of eq '==' is used.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #8 from Konstantin Kolinko <kn...@gmail.com> ---
Created attachment 31231
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31231&action=edit
test.jspx - Failure to trim leading space from fn prefix

Re: r1559555

Not yet.

Testing current 7.0.x (at r1559663) I see the following error
1. Place attached test.jspx into webapps/examples
2. Access http://localhost:8080/examples/test.jspx
3. Expected: "[1]". Actual:

org.apache.jasper.JasperException: /test.jspx (line: 7, column: 63) The
attribute prefix  fn does not correspond to any imported tag library

org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
 org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
 org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:149)

org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1563)
 ...
 org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
 org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1817)
 org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
 ...

In the message the prefix is printed as " fn" with leading whitespace.
The expression on the page is ${1 + fn:length(list)}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Jasper                      |Jasper
            Version|7.0.50                      |unspecified
            Product|Tomcat 7                    |Tomcat 6
   Target Milestone|---                         |default

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #7 from Michael Simons <mi...@simons.ac> ---
Konstantin: Your addendum is fully correct, i can confirm this.

Thanks for your kind reply and the quick solution, highly appreciated. Also
thanks for the workaround, but i guess i'll wait to 7.0.51.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #1 from Michael Simons <mi...@simons.ac> ---
Happens with all named operators

<span class="${foo == 'bar' and 1==1 ? 'bar-span' : 'other-span'}">span</span>  


will break as well.

If used in jspx it only works now as 

<span class="${foo == 'bar' &amp;&amp; 1==1 ? 'bar-span' :
'other-span'}">span</span>    

which is not a really acceptable solution.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #5 from Mark Thomas <ma...@apache.org> ---
Fixed in 8.0.x for 8.0.0 onwards and in 7.0.x for 7.0.51 onwards.

Proposed for 6.0.x.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
I suspected when I read this report that it was a regression caused by the fix
for Bug 55198 and given the versions of Tomcat affected it looks to be very
much the case (although I haven't confirmed it yet).

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #12 from Santosh <pa...@ca.com> ---
It seems this issue is fixed now. Can anyone advice in which 7.0.x version can
I expect the fix to be delivered?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pansa05@ca.com

--- Comment #11 from Mark Thomas <ma...@apache.org> ---
*** Bug 56124 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #3 from Konstantin Kolinko <kn...@gmail.com> ---
(In reply to Konstantin Kolinko from comment #2)
> Ack. Reproducible with your sample file from Comment 0 minus the 'xmlns:c'
> and 'xmlns:fmt' attributes.
> 

Reproducible in 8.0-RC10 and 6.0.38 (release candidate) as well.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #2 from Konstantin Kolinko <kn...@gmail.com> ---
Ack. Reproducible with your sample file from Comment 0 minus the 'xmlns:c' and
'xmlns:fmt' attributes.


> javax.el.ELException: Failed to parse the expression [${currentControllereq'News'?'selectedItem':''}]

Notes:

1. "currentControllereq" is printed without spaces in the above message. Also
the rest of whitespaces are also missing in the message.

2. A workaround is to add braces around the variable name.
The following does work:

... class="${(currentController) eq 'News' ? 'selectedItem' : ''}" ...


3. This issue happens when EL in the value of a tag attribute.

This issue does not happen when EL is in the plain text (body of a tag).
The following does work successfully:

<jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page"
><jsp:directive.page contentType="text/plain"/>
${currentController eq 'News' ? 'selectedItem' : ''}</jsp:root>

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fgiust@apache.org

--- Comment #6 from Mark Thomas <ma...@apache.org> ---
*** Bug 56031 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Mark Thomas <ma...@apache.org> ---
This has been fixed in 6.0.x and will be included in 6.0.39 onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #13 from Yuvaraju <Yu...@ca.com> ---
(In reply to Santosh from comment #12)
> It seems this issue is fixed now. Can anyone advice in which 7.0.x version
> can I expect the fix to be delivered?

Santosh,

Mark Thomson mentioned that will be in 8.0.0 and 7.0.51 onwards. Not sure when
will the 7.0.51 be available.. :-)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 56029] Ternary operator doesn't work as expected inside attributes in jspx pages

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56029

--- Comment #9 from Mark Thomas <ma...@apache.org> ---
If fixed the white space issue in 8.0.x and 7.0.x and added it to the proposal
for 6.0.x

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org