This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes bean name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "bean name" Watch "bean name" New topic
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: 14687
    
  16

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.
 
jQuery in Action, 2nd edition
 
subject: bean name