Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

evaluate EL inside EL

 
Ranch Hand
Posts: 36
jQuery Netbeans IDE Java
  • 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?
 
Marshal
Posts: 67416
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.

 
Bartender
Posts: 1845
10
  • Likes 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
Marshal
Posts: 67416
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always a good suggestion!
 
Lookout! Runaway whale! Hide behind this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic