Thursday, August 22, 2013

Access POST parameters via servlet?

I'm creating a GWT application that, when accessed, will be passed POST parameters (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:
  1. 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.
  2. 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.
  3. 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!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment