Reputation: 2976
I am making a web app which uses RPC as the main communication mechanism between my client and server. One thing I want to do is to prevent a user opening my web app in multiple browser tabs. So I want to assign some tab id based on the login time.
Unfortunately, it is not as simple as I expected. First of all, I do not know how to set cookies from my rpc servelet (RemoteServiceServlet) to the client's browser. I am not sure whether it is doable. If not, I hope there is a way to pass the cookie to the client by modifying the HttpServeletResponse. (I do not want to mix this cookie with my returning data.) Furthermore, how can I get the Response object from client side?
Any help will be appreciated.
EDIT:
I tried to set some cookies in the HttpServletResponse which I got from calling getThreadLocalResponse() But I cannot get them from the client side. Cookies.getCookie(xxx) always returns null.
Upvotes: 0
Views: 76
Reputation: 64541
To access the HttpServletResponse
from your RemoteServiceServlet
, just call getThreadLocalResponse()
(same is available for the request too).
Upvotes: 1