• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL var variable .. scoped to tag ?? Pg456 HFSJ .. Error??

 
swami dorai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pg440 HF clearly mentions the var variable has tag scope, ie, it cannot be used outside the tag.
But in Pg 456, shows that the var="inputURL" is being accessed outside the <c:url> tag. Is this correct.

I would think that the ${inputURL} should be used only in the body of <c:url>

Can someone please confirm this.

Swami
 
Gaurav Sahni
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swami,

u are messing up 2 things here. Agreed, the var attribute, when used with the <c:forEach> has tag scope, but for <c:url> , var has a different meaning.
As per the JSTL1.1 specs, pg. 73, (if u don't have them, click
here)

var attribute is
Name of the exported scoped variable for the
processed url. The type of the scoped variable is
String.


which means, it is the variable, which holds the value of processed URL.( and u can even specify the scope for it). The default scope though is page scope and hence, it is accessible in other parts of the page.

HTH.

Regards,
Gaurav.
 
swami dorai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I mistook every var to have nested visibility.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic