• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt on jsp:useBean

 
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
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!