tags:

views:

323

answers:

1

I am working on converting the functionality of some JSP pages to GWT. I noticed that javax.servlet.http.HttpServletRequest request is an implied object in JSP, and one can obtain the client's refresh count by calling request.getParameter("refreshCount"). I noticed that one can also access this request object in GWT in the service implementation class (extends RemoteServiceServlet) for the client making an RPC call to this service class by calling getThreadLocalRequest(). However, I noticed that the request object has no parameters. How may I possibly get the refresh count of the calling client (through HttpServletRequest or otherwise)?

+4  A: 

I don't think getParameter("refreshCount") is an automatic function of servlets. It looks like it is just getting the value of a refreshCount parameter in your query string (URL). Most likely, some other part of your code is setting that value.

Even if it is being tracked automatically by the Servlet class, that would require maintaining session state for that client. GWT RPC calls don't have any built in session functionality. So if you want to do this, you have two options:

  • You can maintain a "refresh count" variable in the client, and pass it to your RPC method as a parameter.
  • You can pass some kind of session ID into each of your RPC method calls, and track the refresh count on the server side. This might require storing the session in a database, or in some global memory structure.
Peter Recore
this makes sense
P4ndaman