Hi there,
i'm quite new to java and jsp but i want to do the following:
I have the following class:
class DataSet
{
private vector Records;
private int RecordCount;
...
}
class Record
{
private vector ColValues;
}
When saving the dataset to session using putValue("ds",aDataSet);
will the putValue also save all the records in the vector to the session????
Any help is appreciated
Hope you can help me oput Thanx Rim
-
Session variables (3 messages)
- Posted by: Rim Rim
- Posted on: March 15 2001 07:41 EST
Threaded Messages (3)
- Session variables by Andy Nguyen on March 15 2001 09:24 EST
- Session variables by Rim Rim on March 20 2001 03:23 EST
- Session variables by Andy Nguyen on March 27 2001 10:09 EST
- Session variables by Rim Rim on March 20 2001 03:23 EST
-
Session variables[ Go to top ]
- Posted by: Andy Nguyen
- Posted on: March 15 2001 09:24 EST
- in response to Rim Rim
Yes, putValue should save each record in the Vector as well. I would suggest that you have both of your classes also implement Serializable. Also, be sure that any object you put in the Vector also implements Serializable.
One other suggestion. If you're using a servlet container that supports Servlet 2.2, then use setAttribute() instead of putValue(), as putValue() has been deprecated.
Good luck.
Andy -
Session variables[ Go to top ]
- Posted by: Rim Rim
- Posted on: March 20 2001 03:23 EST
- in response to Andy Nguyen
Hi,
thanx for the reply, but what does implements serializable do...
I used HttpSession mysession = request.getSesion(true); to get my session. But what's the difference except that HttpSession has no function for set and getAttribute
Thanx Rim -
Session variables[ Go to top ]
- Posted by: Andy Nguyen
- Posted on: March 27 2001 10:09 EST
- in response to Rim Rim
Implementing Serializable just marks your class as being serializable by the VM. You have to ensure that all instance variables of your class are also serializable. All primitive types in Java are serializable as is String. Any objects that are a part of your class should also implement serializable, or otherwise marked as transient.
getAttribute() and setAttribute() were introduced with the Servlet 2.2 spec, so you if you're using a container that isn't 2.2 compliant, then you should use putValue() and removeValue(). The only container I know of that isn't 2.2 compliant is WebSphere.
Andy