Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

bean name  RSS feed

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we have same bean name in different scopes like person named bean in request and page scopes?

thanks

Harish
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can have beans stored in different scopes with the same name.
 
Harish Yerneni
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" />
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot give the same id to different beans.
Change "person" to something else, it has to be unique.
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!