• Post Reply Bookmark Topic Watch Topic
  • New Topic

Variables Scope Question  RSS feed

 
Ansar Shah
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,



The output of above code part of a JSP is x = 5,3. Please elaborate.

Regards
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Declarations become class members, all other stuff is local.
When the JSP page is translated (before being compiled), this becomes :


Local x is 5, and member x is 3. Thus 5,3.
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scope depends on the tags what we use:

Suppose if you are using <%! declarative it will placed inside the servlet but out side the methods

If you declare a variable in <%= it will be added to the service()
 
Ansar Shah
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you guys!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!