Proxy Servlet for GWT in devmode

One of the problems with using GWT is that when you run in devmode, GWT manages its own instance of a Jetty server (I think it’s a Jetty server anyway). Unless you want to use GWT’s own server implementation, and perhaps even run in on Google AppEngine, you’re going to run into the same origin policy. In order to get around this problem, you have to set up a proxy server of some sort.

This article was originally written on 2010-04-12, but after I reset my website I was asked to republish it. Original article can be found here, courtesy of archive.org.

I found a bit of servlet code written by Stou Sandalski which allows you to do this, made to solve the exact same problem in fact. However, I wanted a proxy which would not only support GET and POST requests, but basically allow me to do whatever I wanted. I also wanted it to send all request headers across to the target server. The only dependency is Apache HttpCore and HttpClient.

Once that’s up and running, you need to add something along these lines to your web.xml in the WEB-INF directory:

7 thoughts on “Proxy Servlet for GWT in devmode

    1. You wouldn’t actually run it within GWT itself, but rather it’s code for a servlet to run on the small server that comes bundled with GWT.

  1. I think I’ve found a more complete solution for a proxy servlet on:

    http://pelle.io/gwt-proxy-servlet/

    https://github.com/pellepelster/gwt-commons/blob/master/de.pellepelster.gwt.commons/src/de/pellepelster/gwt/commons/server/ProxyServlet.java

    I’m not trying to advertise the guy’s website its just that I keep stumbling onto this page so I figure it would be a good idea to post a solution that might fit more people.

    I like the new website by the way :).

    1. Not a problem. To be honest I don’t use GWT any longer, so I can’t comment on whether this implementation is more complete. It’s certainly newer. I’ll leave the links here for others. And thank you for the comments on the new design, I also like it. Originally I designed my own then I went with a stock theme. I’m not a graphic designer and I really shouldn’t try and pretend to be :)

Leave a Reply