| Author |
bean name
|
Harish Yerneni
Ranch Hand
Joined: Sep 15, 2004
Posts: 94
|
|
can we have same bean name in different scopes like person named bean in request and page scopes? thanks Harish
|
SCJP 1.4 | SCWCD 1.4 | SCJD (WIP)
|
 |
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
|
|
|
Yes, you can have beans stored in different scopes with the same name.
|
 |
Harish Yerneni
Ranch Hand
Joined: Sep 15, 2004
Posts: 94
|
|
I got bean name duplicate error when I tried <jsp:useBean id="person" class="foo.Person" scope="page"></jsp:useBean> Dog's name is: <jsp:setProperty name="person" property="name" value="harish" /> Dog's name is: <jsp:getProperty name="person" property="name" /> <jsp:useBean id="person" class="foo.Person" scope="request"></jsp:useBean> Dog's name is: <jsp:setProperty name="person" property="name" value="harish" /> Dog's name is: <jsp:getProperty name="person" property="name" />
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
You cannot give the same id to different beans. Change "person" to something else, it has to be unique.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
|
|
Yes, Satou is correct. Your original question is regarding having beans in different scopes with the same name. That is possible. It's not possible to have two beans with the same id on the same page.
|
 |
 |
|
|
subject: bean name
|
|
|