Bug 42565 - jsp /expression language ternary expression without space before colon stopped working
jsp /expression language ternary expression without space before colon stoppe...
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Jasper
unspecified
Other All
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
: 43714 (view as bug list)
Depends on: 45511
Blocks:
  Show dependency tree
 
Reported: 2007-06-01 08:43 UTC by Thomas Wiesel
Modified: 2014-02-17 13:56 UTC (History)
2 users (show)



Attachments
Patch for this bug (173.08 KB, patch)
2007-10-03 17:13 UTC, Lucas Galfaso
Details | Diff
Cleaner patch (105.11 KB, patch)
2007-10-14 11:53 UTC, Lucas Galfaso
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiesel 2007-06-01 08:43:44 UTC
the following jspx works fine in tomcat 5.5.23 but fails in 6.0.13

<?xml version="1.0" encoding="iso-8859-1"?>
<html
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:jsp="http://java.sun.com/JSP/Page">
	
<jsp:output omit-xml-declaration="true"
	doctype-root-element="html"
	doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />	

	<head>
		<title>error!!!</title>
	</head>
	<body>
			<p>${true? (false?true:false):false}</p>
	</body>
</html>

org.apache.jasper.JasperException: An exception occurred processing JSP page
/test.jspx at line 15

12: 		<title>error!!!</title>
13: 	</head>
14: 	<body>
15: 			<p>${true? (false?true:false):false}</p>
16: 	</body>
17: </html>


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

javax.el.ELException: Error Parsing: ${true? (false?true:false):false}
	org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:125)
	org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:146)
	org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:190)
	org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
	org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:922)
	org.apache.jsp.test_jspx._jspService(test_jspx.java:62)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.apache.el.parser.ParseException: Encountered "true: false" at line 1, column 16.
Was expecting one of:
    "(" ...
    <IDENTIFIER> ...
    <NAMESPACE> <IDENTIFIER> ...
    
	org.apache.el.parser.ELParser.generateParseException(ELParser.java:1874)
	org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:1754)
	org.apache.el.parser.ELParser.NonLiteral(ELParser.java:1136)
	org.apache.el.parser.ELParser.ValuePrefix(ELParser.java:1030)
	org.apache.el.parser.ELParser.Value(ELParser.java:978)
	org.apache.el.parser.ELParser.Unary(ELParser.java:960)
	org.apache.el.parser.ELParser.Multiplication(ELParser.java:723)
	org.apache.el.parser.ELParser.Math(ELParser.java:643)
	org.apache.el.parser.ELParser.Compare(ELParser.java:455)
	org.apache.el.parser.ELParser.Equality(ELParser.java:349)
	org.apache.el.parser.ELParser.And(ELParser.java:293)
	org.apache.el.parser.ELParser.Or(ELParser.java:237)
	org.apache.el.parser.ELParser.Choice(ELParser.java:203)
	org.apache.el.parser.ELParser.Expression(ELParser.java:183)
	org.apache.el.parser.ELParser.NonLiteral(ELParser.java:1122)
	org.apache.el.parser.ELParser.ValuePrefix(ELParser.java:1030)
	org.apache.el.parser.ELParser.Value(ELParser.java:978)
	org.apache.el.parser.ELParser.Unary(ELParser.java:960)
	org.apache.el.parser.ELParser.Multiplication(ELParser.java:723)
	org.apache.el.parser.ELParser.Math(ELParser.java:643)
	org.apache.el.parser.ELParser.Compare(ELParser.java:455)
	org.apache.el.parser.ELParser.Equality(ELParser.java:349)
	org.apache.el.parser.ELParser.And(ELParser.java:293)
	org.apache.el.parser.ELParser.Or(ELParser.java:237)
	org.apache.el.parser.ELParser.Choice(ELParser.java:203)
	org.apache.el.parser.ELParser.Expression(ELParser.java:183)
	org.apache.el.parser.ELParser.DynamicExpression(ELParser.java:155)
	org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:52)
	org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:93)
	org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:146)
	org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:190)
	org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
	org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:922)
	org.apache.jsp.test_jspx._jspService(test_jspx.java:62)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Comment 1 Niall Pemberton 2007-06-15 06:45:41 UTC
The problem seems to be with the "false?true:false" part of the expression (the
same excepion is thrown specifying just "${false?true:false}".

As a workaround, adding a space before the colon seems to resolve it - both the
following work OK:

${false?true :false}
${true? (false?true :false):false}

Now to understand JavaCC/JJTree to work out why...
Comment 2 Takis Bouyouris 2007-06-22 02:46:29 UTC
I confirm the same problem! I am trying to keep up to date and want to move to
Tomcat 6, too.

Also, it is not a Windows specific problem... Same goes for Tomcat 6 in Linux1

It is a very annoying problem for people who have the - good - habit of using EL
expressions. Anybody knows if it is truly considered a bug and if it is going to
be fixed?
Comment 3 Magnus Melin 2007-07-02 06:10:29 UTC
I can confirm this too. If the ternary expression doesn't have space before the
colon it doesn't work, as pointed out in comment 1.
Comment 4 Magnus Melin 2007-10-02 01:54:47 UTC
This is really blocking me from upgrading to tomcat6.
Comment 5 Lucas Galfaso 2007-10-03 17:13:21 UTC
Created attachment 20913 [details]
Patch for this bug

This patch fixes this bug (possible incorrect presumption that the presence of
a ":" involves a function call when a value was specified) and another minor
bug (valid namespaces names are not detected as such.) I was not able to find
this bug, but checking the grammar and checking the specification makes this
very simple to detect. The fix for this second bug does not follow the standard
guidelines but it is closer to doing so than the previous grammar.
Comment 6 Lucas Galfaso 2007-10-14 11:53:39 UTC
Created attachment 20975 [details]
Cleaner patch

Cleaner patch
Comment 7 Lucas Galfaso 2007-10-14 11:54:48 UTC
The only real modification is on the .jjt file, everything else was auto
generated by jjtree.
Comment 8 Lucas Galfaso 2007-10-28 08:39:21 UTC
*** Bug 43714 has been marked as a duplicate of this bug. ***
Comment 9 Dennis 2007-11-13 07:43:30 UTC
I can reproduce the bug only if the operand left of the colon is *NOT* a string
literal or a numeric literal.
Comment 10 Lucas Galfaso 2007-11-13 17:58:47 UTC
(In reply to comment #9)

> I can reproduce the bug only if the operand left of the colon is *NOT* a string
> literal or a numeric literal.

Can you reproduce the bug with the test case you are using is you apply the patch?
Comment 11 Magnus Melin 2008-05-16 00:58:52 UTC
So can the patch be checked in? Would like to move to tc6...
Comment 12 Thomas Wiesel 2008-06-26 07:22:17 UTC
(In reply to comment #11)
> So can the patch be checked in? Would like to move to tc6...
> 

the patch works fine for us, please check in, thanks a lot!
Comment 13 Mark Thomas 2008-07-10 14:00:15 UTC
Many thanks for the patch.

It has been applied to trunk and proposed for 6.0.x
Comment 14 Mark Thomas 2008-07-31 07:13:16 UTC
This was applied to 6.0.x and included in 6.0.18 onwards.

However, this patch caused a regression: bug 45511