{"id":308,"date":"2009-06-16T02:55:40","date_gmt":"2009-06-16T09:55:40","guid":{"rendered":"http:\/\/www.kernelcrash.com\/blog\/?p=308"},"modified":"2009-06-16T02:55:40","modified_gmt":"2009-06-16T09:55:40","slug":"using-perl-cgi-scripts-with-gwt","status":"publish","type":"post","link":"https:\/\/www.kernelcrash.com\/blog\/using-perl-cgi-scripts-with-gwt\/2009\/06\/16\/","title":{"rendered":"Using perl CGI scripts with GWT"},"content":{"rendered":"<p>Google Web Toolkit (GWT)\u00a0 has a great development environment using the built in <a href=\"http:\/\/www.mortbay.org\/\">jetty<\/a> 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).<\/p>\n<p>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;<\/p>\n<blockquote>\n<pre>&lt;servlet&gt;\r\n\u00a0\u00a0\u00a0 &lt;servlet-name&gt;perl&lt;\/servlet-name&gt;\r\n\u00a0\u00a0\u00a0 &lt;servlet-class&gt;org.mortbay.servlet.CGI&lt;\/servlet-class&gt;\r\n&lt;\/servlet&gt;\r\n\r\n\u00a0&lt;servlet-mapping&gt;\r\n\u00a0\u00a0\u00a0 &lt;servlet-name&gt;perl&lt;\/servlet-name&gt;\r\n\u00a0\u00a0\u00a0 &lt;url-pattern&gt;\/cgi-bin\/*&lt;\/url-pattern&gt;\r\n&lt;\/servlet-mapping&gt;<\/pre>\n<\/blockquote>\n<p>Now create a cgi-bin directory underneath your war directory and create some perl scripts in there. You&#8217;ll need to make them executable, but that&#8217;s pretty\u00a0 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&#8217;t seem to work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Web Toolkit (GWT)\u00a0 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":3,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kernelcrash.com\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}