Accessing a javabean in a servlet
1 posts in topic
Flat View  Flat View

Posted By:   nguyen_huy
Posted On:   Saturday, October 5, 2002 11:06 PM


I'm using a javabean to store information from my jsp pages. How do I retrieve the info afterward stored in the javabean from my servlet ?

I'm using a servlet at the end to retrieve all the information to send it to the database. Should this just be done from a jsp page ? There's a lot of data...so i'm concern with performance.

Re: Accessing a javabean in a servlet

Posted By:   Lasse_Koskela  
Posted On:   Monday, October 7, 2002 01:02 AM

When you store information to a JavaBean, you are storing the JavaBean into the HttpSession. The servlet can access the JavaBean through the session object also.

// get the session object
HttpSession session = request.getSession(true);

// get the JavaBean from the session object
MyJavaBean bean = (MyJavaBean) session.getAttribute("myJavaBean");

// use the JavaBean
String someValue = bean.getSomeValue();
About | Sitemap | Contact