You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Aaron Lindsey <aa...@redneptune.com> on 2001/04/26 18:12:47 UTC
setAttribute/getAttribute problem
I'm having problems attaching an object to the request object in a servlet
and pulling that object out again after forwarding to a jsp. I've created
a bean called PopBean that I attach to the request. After forwarding to a
jsp, I attempt to retrieve it from the request object and cast back to
PopBean. I get a ClassCastException. If I run a getClass().getName() the
result is PopBean. However, instanceof returns false when compared to
PopBean. I can create new instances of PopBean in the jsp with no
problem. I also can pass any of the standard java classes like Vector,
String, etc. and pull them out with no problem. This problem only happens
with classes that I have created myself.
Does anyone have any ideas? I've been wrestling with this for a while
without success. BTW, I'm using Tomcat 3.2.1 on Solaris. Thanks.
Aaron
RE: setAttribute/getAttribute problem
Posted by CPC Livelink Admin <cp...@fitzpatrick.cc>.
Well, it works for me - that is I can set request attributes in a servlet
and get them later in a JSP. Make sure you are using a forward, and not a
response.sendRedirect is the only advice I can give quickly - but I'll think
on it a while.
Paul
-----Original Message-----
From: novotny@bullwinkle.lbl.gov [mailto:novotny@bullwinkle.lbl.gov]On
Behalf Of Jason Novotny
Sent: Thursday, April 26, 2001 3:05 PM
To: tomcat-user@jakarta.apache.org
Cc: aaron@redneptune.com
Subject: Re: setAttribute/getAttribute problem
I stumbled into the same problem yesterday without any luck. Apparently
using request.set/getAtttribute is pretty much useless in my experience. I
had to stick the data in the session instead using session.set/getAttribute.
Not a very attractive solution, but it works anyway.
Jason
Aaron Lindsey wrote:
> I'm having problems attaching an object to the request object in a servlet
> and pulling that object out again after forwarding to a jsp. I've created
> a bean called PopBean that I attach to the request. After forwarding to a
> jsp, I attempt to retrieve it from the request object and cast back to
> PopBean. I get a ClassCastException. If I run a getClass().getName() the
> result is PopBean. However, instanceof returns false when compared to
> PopBean. I can create new instances of PopBean in the jsp with no
> problem. I also can pass any of the standard java classes like Vector,
> String, etc. and pull them out with no problem. This problem only happens
> with classes that I have created myself.
> Does anyone have any ideas? I've been wrestling with this for a while
> without success. BTW, I'm using Tomcat 3.2.1 on Solaris. Thanks.
>
> Aaron
--
Jason Novotny novotny@george.lbl.gov
Home: (510) 610-8360 Work: (510) 486-8662
NERSC Distributed Computing http://www-didc.lbl.gov
Re: setAttribute/getAttribute problem
Posted by Jason Novotny <JD...@lbl.gov>.
I stumbled into the same problem yesterday without any luck. Apparently
using request.set/getAtttribute is pretty much useless in my experience. I
had to stick the data in the session instead using session.set/getAttribute.
Not a very attractive solution, but it works anyway.
Jason
Aaron Lindsey wrote:
> I'm having problems attaching an object to the request object in a servlet
> and pulling that object out again after forwarding to a jsp. I've created
> a bean called PopBean that I attach to the request. After forwarding to a
> jsp, I attempt to retrieve it from the request object and cast back to
> PopBean. I get a ClassCastException. If I run a getClass().getName() the
> result is PopBean. However, instanceof returns false when compared to
> PopBean. I can create new instances of PopBean in the jsp with no
> problem. I also can pass any of the standard java classes like Vector,
> String, etc. and pull them out with no problem. This problem only happens
> with classes that I have created myself.
> Does anyone have any ideas? I've been wrestling with this for a while
> without success. BTW, I'm using Tomcat 3.2.1 on Solaris. Thanks.
>
> Aaron
--
Jason Novotny novotny@george.lbl.gov
Home: (510) 610-8360 Work: (510) 486-8662
NERSC Distributed Computing http://www-didc.lbl.gov