Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt on jsp:useBean  RSS feed

 
Harshit Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will the following code work properly inside a jsp?




As far as I know, jsp:usebean creates a new variable in the generated servlet code whose name is specified by the 'id' attribute. So after usebean if we declare another variable of the same name in a scriptlet, it will amount to duplicate declaration. Am I correct?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True.

Try to find out what happens if you do it this way :
 
Harshit Patel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Declaring the variable in a declaration should work because the scopes will be different (usebean would be declared inside service method, while jsp declaration would be at the class-level)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!