Gary Albers@TIMEWEB
02/10/2000 03:36 PM

Hi Folks,

Is there any special 'trick' to being able to access an object (bean) from
within a
servlet and a jsp page?  I am not getting the same instance of the bean
when I
try to access a bean from the servlert and then a jsp page.

I do the following:
 - create a bean in a servlet,
 - get the session from the request object
 - put the bean in the session using: session.setAttribute("beanName",
bean)
 - forward to a jsp page using: RequestDispatcher.forward()
 - in the jsp page, access the bean
     <%@ page session="true"%>
     <jsp:useBean id="beanName" scope=session  class=... />

In the jsp page, it does not find the bean so it creates a new one.

I can see from my debugging that the session object, before and after the
'forward',
is the same.  However, it does not have the save attributes.  I added debug
print lines
that show the identity of the bean before and after I do the forward() and
that appears
to be the point at which the bean I created is not found and the jsp page
creates a new one.

When control returns from the call to RequestDispatcher.forward(), I was
able to
access the correct instance of the bean.

Why did the jsp page not find the bean the servlet put in the session?

I could really use some help on this and would appreciate any suggestions.


Thanks,
Gary

BTW, I am using Orion 8.2, on NT with JDK 1.2.2


Reply via email to