• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp usebean sharing issues

 
Luanne Coutinho
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using a bean called productTransfer in two different JSP's:
JSP 1:
<jsp:useBean id="transferbean" class="transactions.productTransfer" scope="session"/>
JSP 2:
<jsp:useBean id="invTransfer" class="transactions.productTransfer" scope="session"/>

While I am still in the same session, if I first use JSP 1 and then use JSP 2 after that, will my instance of productTransfer (invTransfer) be the same as the instance used in JSP 1 as transferBean?
i.e. Is there just one instance created of productTransfer irrespective of what the bean ID is in different JSPs?
Thanks
Luanne
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Luanne Coutinho,
For each bean id seperate instance of your bean class will be created.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. The beans are created as entries in an attribute Map in the session (or whatever other scope you use) using the id as the key. Since you gave the beans separate id values, each is a separate entry in the map. If you want to share the same instance, they must have the same id.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!