Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Expression and EL  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are these two always same??

<%= something%> and ${something}

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rathi ji:
Are these two always same??


No, in fact they're never the same -- unless you've done something special before-hand to make sure that there is a scripting variable and a scoped variable that refer to the same object.
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${something} translates closer to <%= pageContext.findAttribute("something") %>
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<= request.getParameter("key")%>

equals to

${param.key}

Right?
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rathi ji:
Are these two always same??

<%= something%> and ${something}

Thanks.


Actually these two are same:

<%= "something"%>

and

${"something"}
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stefan Evans:
${something} translates closer to <%= pageContext.findAttribute("something") %>


${something} will return something only if there is 'something' attribute present in one of the scope...
 
Abcd
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually both mean the same. but they are used in different technologies
one in jsf and other in jstl
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abcd
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${something} will return something only if there is 'something' attribute present in one of the scope...


I don't think it has to be a scoped attribute.
It could just as well be a JSP variable of that name declared using the variable directive and set in a tag file (or a tld for a tag using the <variable> element)?
Within the tag file a call to ${something} would then return the value of 'something' even though it is not a scoped attribute I think.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ed Ward:

I don't think it has to be a scoped attribute.
It could just as well be a JSP variable of that name declared using the variable directive and set in a tag file (or a tld for a tag using the <variable> element)?
Within the tag file a call to ${something} would then return the value of 'something' even though it is not a scoped attribute I think.


The way that such variables are set usually involves creating a scoped variable which is used to communicate the value from the tag to the page code which uses it to set the value of a scripting variable.

So even in this case, the EL sees the scoped variable. If there is no scoped variable for whatever reason, the EL will have no access.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!