Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing session beans to servlets

Status
Not open for further replies.

Sudmill

Programmer
Apr 20, 2001
65
GB
Hi,

Please excuse the newbie questions in advance as Im fairly new to JSP.

1) I am currently passing session beans to other beans in the following way. Is this the best method ?

<jsp:useBean id=&quot;loginConn&quot; scope=&quot;session&quot; class=&quot;com.company.project.LoginBean&quot;/>
<jsp:useBean id=&quot;dataBean&quot; scope=&quot;session&quot; class=&quot;com.company.project.DataBean&quot;>
<jsp:setProperty name=&quot;databean&quot; property=&quot;loginbean&quot; value=&quot;<%=loginConn.getLoginbean()%>&quot;/>
</jsp:useBean>

2) How would a servlet fetch session beans that have been instantiated in a JSP page?
(i.e. how would a servlet fetch and use the &quot;dataBean&quot; bean from the above example ?)

Cheers

John (Sudmill)
 
Hi John,

Just get it from the session ie:
DataBean dataBean = (DataBean)session.getAttribute(&quot;databean&quot;);

David[afro]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top