|
Replies:
2
-
Last Post:
Apr 4, 2008 5:17 AM
by: writtmeyer
|
|
|
|
|
|
|
how to store json data in browser
Posted:
Apr 3, 2008 9:56 AM
|
|
|
Hello,
I am writing a major project with glassfish. We are using a lot of restful services and servlets that talk via browser tru json.
Imagine my page loads first, the init method is called in js, and then the dom tree is modified as the user interacts. when the user navigates to a different page within my server, and then hits the back button, the init method in my js executes, and all the data I polled from my server gets destroyed.
how can I overcome this limitation? I guess I could store some data in session object, but that would still consume bandwidth. is there no way to store data inside the browser, like in the window. object?
I realize this is little off topic, but I need some architectural advice - that is glassfish centric.
Best Regards, seg
|
|
|
|
|
|
|
Re: how to store json data in browser
Posted:
Apr 4, 2008 4:57 AM
in response to: segfault2007
|
|
|
You can store session data on the client side in cookies. Cookies do consume bandwidth as they are sent back and forth to the server, and if the session objects are large (over ~4k) can fail outright. (If the json you are storing is likely to be smaller than this then I would use cookies - the performance hit will likely be unnoticable. If you are worried about this then try benchmarking it before jumping to conclusions.)
If the amount of data really is large, I would suggest creating an ajax application where there is no page reload for as long as the data is needed (And hence no data loss).
Other solutions could include use of frames (Where data is stored in a parent frame and the application is opened in a child frame, with the data is accessed from the document.parent node. The disadvantage to this approach is you lose your url, and would have to do some special coding to get bookmarkability (Like using in page links - like GWT.) This approach would probably suck from the point of view of SEO.
Hope this helped
Tofarr
|
|
|
|
|
|
|