• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is EL evaluated if it's inside quotes

 
maih fhil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will the EL inside the following line be evaluated
<a href='mailto:${initParam['master-email']}'>
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maih,

EL expressions (of the form ${...}) are evaluated when they
appear in template text or action attributes, unless you
specified they should not be, either in the Deployment Descriptor
or the jsp.

Kind regards,

Gian
 
maih fhil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply
But it is given in the HFSJ that this line is executed properly even though it is inside the quotes
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I see...

I've tried two options in a sample application, and



and



both work properly.

Kind regards,

Gian
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Careful! There's a tiny trick to this!

The anchor tag allows the EL in quotes any which way, just as you could anywhere in template text. HOWEVER, this is not true for attributes of evaluated (standard and custom) tags!

For example, <cut value='${param['test']}'/> or <cut value="${param["test"]}"/> should give an error. When the tags get evaluated, the compiler has no clue which of the quotation marks is the start or end because they're all the same.

If your EL expression needs to use quotes inside an evaluated tag's attribute value, you need to make sure it uses the kind of quotes that you aren't using to wrap the attribute's value, like <cut value='${param["test"]}'/> or <cut value="${param['test']}"/> !!!

In the real world, I think you're more likely to see even the html tags used the same way as evaluated tags, with the inner quotes being different than the outer quotes (out of habit), but it's perfectly valid even if you don't.
[ January 10, 2008: Message edited by: Marc Peabody ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic