• 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:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Question about Java Beans  RSS feed

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know Java Beans can be defined in a scope of page, request, session or application, and it exists as attributes of scope object.
I'm using MVC model, when servlets invoke EJBs to get the data, it puts data into the attributes of the scope Object(like session or request), and forward it to JSPs, the JSP then access the scope objects to display data.
I wonder, since Java Bean defined like <jsp:useBean id='..' class='...' scope='session'> still exists in session object, do I need to just use this tag to get the Java Bean instance in Session Object or instead access the session object to get the Java Bean?
any help appreciated!!!
 
Author
Posts: 93
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Robert Strong:

I wonder, since Java Bean defined like <jsp:useBean id='..' class='...' scope='session'> still exists in session object, do I need to just use this tag to get the Java Bean instance in Session Object or instead access the session object to get the Java Bean?
any help appreciated!!!


If I understand your question Robert, as long as you have the item in the session, you should be able to use the <jsp:bean> tag to get access to it. You should not have to first get a reference to the session object then pull the Java Bean out. The <tag> should take care of that.
Thanks,
John Carnell
 
Bartender
Posts: 20727
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you provided the bean name, that was a key to a dictionary. The "scope=" parameter indicated WHICH dictionary, so by saying "scope=session", you've said that the bean should be located in the session object - which is a dictionary, courtesy of the set/getAttribute methods.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!