Search code examples
javagwtrpchttpsession

GWT HTTP Session avaliabilty on client


Is it the only way that making an RPC call in GWT for getting HTTP session attributes ?

Is there any way to get them directly in the client side code without making an rpc call ?

If browser is maintaining session why we need to go to the server again for a session variable?


Solution

  • Is it the only way that making an RPC call in GWT for getting HTTP session attributes ?

    For getting session attributes you can use different approach (for example with JSON). GWT-RPC is just one mechanism for passing Java objects to and from a server over standard HTTP. Read this article: Communicating with the server.

    is there any way to get them directly in the client side code without making an rpc call ?

    Shortly, no you cannot access them unless you retrieve them from server. Because all GWT applications run as JavaScript code in the end user's web browser, but the session lives in the server side. So you have to ask them from your server.

    If browser is maintaining session why we need to go to the server again for a session variable ?

    You have a wrong perception about sessions, they are not maintained by your browser. For controlling the session you have to call to the server-side with asynchronous callbacks or with another technique. Or if you mean Client side web sessions, you can control them with Cookies.