Reputation: 61
I have written a shopping cart application with a shopping cart object being stored in the http session. On each request I'm returned a different object instance. Is this the expected behaviour?
If I modify my shopping cart object, do I need to store it in the session again every time (at the moment my changes are lost because I'm not doing this)?
Works fine in development but not live. Is this to because of the distributed architecture of GAE or am I doing something wrong?
I really hope you can help or confirm my thoughts on this. Thanks in advance.
Chris
p.s. i'm using struts2, but don't know if that is possibly a problem
Upvotes: 3
Views: 104
Reputation: 180927
Yes, due to the session not necessarily being stored in memory, your session values will be copies, not references to the same objects.
From the GAE docs;
Because App Engine stores session data in the datastore and memcache, all values stored in the session must implement the java.io.Serializable interface.
In other words, GAE will serialize/deserialize your sessions as needed, generating copies.
Upvotes: 2