File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bean name