File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 63865

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] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
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: 63865

Always a good suggestion!
I agree. Here's the link:
subject: evaluate EL inside EL
jQuery in Action, 3rd edition