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 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
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

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
Bartender

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

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

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