Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can a variable with same name present in more than one scope?

 
yamini nadella
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can a variable with same name present in more than one scope?
assume first I declared a variable in page scope and then I declared the same variable in application scope then what happens?
 
arnel nicolas
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is YES, but should be in a different scope.

arnel
 
Ashish Sarin
author
Ranch Hand
Posts: 432
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is possible. But it is recommended that you try not to have variables with same name in different scopes. If you do have such a case in which variable with the same name is present in lets say, page and session scopes then when the EL expression is used which requires rearching the various scopes then it will return the variable in the scope which was searched first ie. page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic