Using perl CGI scripts with GWT

Google Web Toolkit (GWT)  has a great development environment using the built in jetty server, but the default setup is aimed at developing servlet style server-side programs. If you want your GWT client to simple do some GETs or POSTs to a CGI script somewhere, my initial thoughts were to use a different web server on a different port, but then you hit the SOP (single origin policy) problem. Basically any server communication needs to be to the same web server (ie. the jetty one).

The simple answer for me was to tell the jetty server to serve CGI scripts. To do this, edit your war/WEB-INF/web.xml file so that the following lines are added in;



Now create a cgi-bin directory underneath your war directory and create some perl scripts in there. You’ll need to make them executable, but that’s pretty  much it (I did this under OSX). The only other key problem I had is that when you create a new GWT project in eclipse you have to untick the option for Google App Engine, otherwise the jetty changes don’t seem to work.