Tuesday, 27 August 2013

Access GWT POST parameters via servlet?

Access GWT POST parameters via servlet?

I'm creating a GWT application that will be accessed by a POST request,
which contains parameters I care about (user id, etc.).
All the reading I've done so far has led me to believe that I should
create a servlet (I'm using tomcat) that will handle the POST parameters
and then forward to my GWT application. I've gotten this working, but I'm
still having trouble passing this data to my application. I've seen 3
suggested approaches:
Save data to context: I have this working right now, but I'm not happy
with it. When the servlet is accessed, I parse the parameters and update
the context of my GWT web application and then forward to the application
where I make an RPC call to read the context. This does what I want it to,
but this creates a race condition when multiple users try to access the
application at the same and the context is rapidly changing.
Store data in session: I've tried saving the data to the request session
in my servlet, and then doing a
"response.sendRedirect(response.encodeRedirectURL("url"))" but I've not
been able to access the same session. When I do
"this.getThreadLocalRequest().getSession()" I always get a new/different
session, so I assume I'm mucking this up somewhere.
Pass data in URL: My application will be opened in an iframe, meaning
"Window.location.getParameter()" will not be usable.
Any help would be greatly appreciated! I'm still learning GWT and web
development in general so don't be afraid to call me out on any obvious or
silly mistakes.
Thanks!

No comments:

Post a Comment