Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Java Beans

 
Robert Strong
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!!!
 
John Carnell
Author
Ranch Hand
Posts: 71
  • 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
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic