To store a Java Object in session (HTTPRequest or HTTPResponse), just make
any Object (POJO or something more complicated) implement
serializable. Keep in mind, you don't need to code an extra functions,
just add the implements serializable to Class definition.
-Jay
At 07:42 AM 4/27/2005 -0400, you wrote:
>If I use the "session" to store things, 1. Can I use simple java types? 2.
>Do I have to use Java Beans (extends serializable)?
>
>David Whitehurst
>
>Viorel Dragomir wrote:
>
>>Yes.
>>But you can set some attributes of the objects as [ transient ] to not be
>>serialized. So you don't have to make all objects in the package serializable.
>>
>>
>>
>>
>>Viorel Dragomir
>>
>>.
>>..
>>-------------------------------------------------------------------
>>
>>
>>
>>----- Original Message ----- From: David Whitehurst To:
>>tomcat-user@jakarta.apache.org Sent: Wednesday, April 27, 2005 11:31
>>Subject: Nervous about Sessions ...
>>
>>
>>Long ago a multi-client, multi-Oracle application was written using
>>Struts. Recently, we had a 4 in 22,000 record data integrity issue. I
>>found one client implementation that used prepared statements but the
>>primary key was being used e.g. "update mytable set a= ?, b=? where
>>pri_key = " + pkey + " ' "; ...whoa! I said, called the developer and we
>>had a talk.
>>
>>Then, I also found that where we use a HashMap object it is not
>>synchronized. I suspect that was the data problem, i.e. two records
>>saved by two different people, and the data was the same for the
>>different records in the same Oracle second.
>>
>>I'm looking for comments about the use of this HashMap on "requests" but
>>I'm also nervous now where I use Strings in the "session" e.g. a
>>clientname, username, etc. My concern started when I read the posts about
>>the non-serializable objects in the session. Do all java objects placed
>>in the session have to be serializable?
>>Thanks,
>>
>>David L. Whitehurst
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
|