GWT client static variable versus Server side Session object

509 views
Skip to first unread message

Leung

unread,
Jan 10, 2012, 5:46:33 AM1/10/12
to google-we...@googlegroups.com
Hi,
 
If I need to save some information of the login user, e.g locale, should I put it on server side session object? Or declare a class and a static varible on the gwt client folder of the framework?
 
Can you please compare and explain the benefits of these 2 ways?
 
Thanks
 
     

Uemit

unread,
Jan 10, 2012, 8:29:14 AM1/10/12
to google-we...@googlegroups.com, Leung
Well it depends. 
If you use a server side session object the information (i.e. locale) will be probably stored in a Cookie and transmitted whenever you initiate a HTTP request (communicate with the backend) and it is always available on the backend.
If you store it as a static variable you have to add to manually to the request to the backend. Furthermore with Cookies you can specify a lifespan which goes beyond the session and the information is  also available when you refresh the browser. That's not possible with client side variable unless you use HTML5 localcache. 

to summarize:

Server side session:
Advantages: 
  • transmitted in every request (so it's always available on the backend)
  • lifespan beyond current session (via Cookie expire date)
Disadvantages:
  • Always transmitted -> small overhead 

Client side static variable:
Advantages:
  • You can control when the information is transmitted
Disadvantages:
  • Information is lost if you refresh or close the browser








Reply all
Reply to author
Forward
0 new messages