File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

evaluate EL inside EL

 
Jelo Nehuptra
Ranch Hand
Posts: 36
Java jQuery Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to render something like this:

File 'asdf.txt' has an invalid file format.
but my code

renders it as:
File '${param.fileName}' has an invalid file format.

Does anyone know how can I get the container to evaluate the ${param.fileName} using EL but not the core if tags?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not be using the ternary operator for this, but using the <c:if> tag. Why not use what's clearest and most appropriate? Embedding HTML inside strings is a poor practice, and ternary operator is intended as a simple expression switch, not as a replacement for a conditional statement.

And, no you cannot embed an EL expression inside another. The ${} delimiters enclose the entire EL expression and there is no need nor allowance for nesting them.

 
Stefan Evans
Bartender
Posts: 1640
9
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As another suggestion seeing as we're using JSTL.
Pull the static string out into a resource bundle:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always a good suggestion!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic