jQuery in Action, 3rd edition
The moose likes JSP and the fly likes evaluate EL inside EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "evaluate EL inside EL" Watch "evaluate EL inside EL" New topic

evaluate EL inside EL

Jelo Nehuptra
Ranch Hand

Joined: Oct 08, 2011
Posts: 36

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

Joined: Jan 10, 2002
Posts: 63349

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1518
As another suggestion seeing as we're using JSTL.
Pull the static string out into a resource bundle:

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63349

Always a good suggestion!
I agree. Here's the link: http://aspose.com/file-tools
subject: evaluate EL inside EL
It's not a secret anymore!