File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes EL and ? : construct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "EL and ? : construct" Watch "EL and ? : construct" New topic
Author

EL and ? : construct

DenisS Simpson
Greenhorn

Joined: Feb 10, 2006
Posts: 4
I am trying to do something like this
${true ? 'A': 'B'}

but I get an error

An error occurred while evaluating custom action attribute "value" with value "${true ? 'A' : 'B'}": Encountered "?", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||"] (null)

According to O'Reilly's "JavaServer Pages" condition ? ifTrue : ifFalse operator is allowed. Is book wrong?

PS I am using WebLogic
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

What version of JSP are you using? The ternary operator was introduced to the EL with JSP 2.0.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
DenisS Simpson
Greenhorn

Joined: Feb 10, 2006
Posts: 4
JSP 2.0
Running on WebLogic 8
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Should work then. I use it regularly on Tomcat 5 and Resin 3.

Is your web.xml declared as a Servlets 2.4 deployment descriptor? If not, the EL shouldn't be enabled on the pages at all, but I don't know how closely weblogic follows the JSP 2.0 spec and it might just be using some weird pre-JSP 2.0 compatability mode.
DenisS Simpson
Greenhorn

Joined: Feb 10, 2006
Posts: 4
I don't have an entry for Servlets 2.4 descriptor.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

See this JSP FAQ entry.
[ February 10, 2006: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL and ? : construct