{"id":674,"date":"2005-05-09T13:32:52","date_gmt":"2005-05-09T17:32:52","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=674"},"modified":"2005-05-09T13:32:52","modified_gmt":"2005-05-09T17:32:52","slug":"showing-googles-web-accelerator-the-door-using-java-servletfilter","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2005\/05\/09\/showing-googles-web-accelerator-the-door-using-java-servletfilter\/","title":{"rendered":"Showing Google&#8217;s Web Accelerator the door using Java \/ ServletFilter"},"content":{"rendered":"<p>The guys over at 37 Signals posted an explanation of <a href=\"http:\/\/37signals.com\/svn\/archives2\/google_web_accelerator_hey_not_so_fast.php\">why they think the Google Web Accelerator is a bad idea<\/a> and a link to a page which shows how you can <a href=\"http:\/\/david.backpackit.com\/pub\/37983\">disable the Google Web Accelerator by analyzing HTTP headers using Ruby<\/a>.  I&#8217;m don&#8217;t really care to discuss why you think the GWA is good or bad, but in case you think it&#8217;s bad, here&#8217;s the same thing implemented as a ServletFilter (here&#8217;s the <a href=\"http:\/\/www.houseoffusion.com\/cf_lists\/messages.cfm\/Threadid=40069&amp;forumid=4&amp;#205879\">same thing for ColdFusion<\/a>):<br \/>\n<code><br \/>\npublic void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)<br \/>\n&nbsp;&nbsp;throws IOException, ServletException {<br \/>\n&nbsp;&nbsp;HttpServletRequest httpreq = (HttpServletRequest)req;<br \/>\n&nbsp;&nbsp;HttpServletResponse httpres = (HttpServletResponse)res;<br \/>\n&nbsp;&nbsp;if (httpreq.getHeader(\"X-moz\") != null &amp;&amp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;httpreq.getHeader(\"X-moz\").equalsIgnoreCase(\"prefetch\")) {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;httpres.sendError(HttpServletResponse.SC_FORBIDDEN);<br \/>\n&nbsp;&nbsp;} else {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;chain.doFilter(req, res);<br \/>\n&nbsp;&nbsp;}<br \/>\n}<br \/>\n<\/code><br \/>\nAdd the following to your web.xml:<br \/>\n<code><br \/>\n&lt;filter&gt;<br \/>\n&nbsp;&nbsp;&lt;filter-name&gt;gwa&lt;\/filter-name&gt;<br \/>\n&nbsp;&nbsp;&lt;filter-class&gt;com.mycompany.web.filters.GWAFilter&lt;\/filter-class&gt;<br \/>\n&lt;\/filter&gt;<br \/>\n&lt;filter-mapping&gt;<br \/>\n&nbsp;&nbsp;&lt;filter-name&gt;gwa&lt;\/filter-name&gt;<br \/>\n&nbsp;&nbsp;&lt;url-pattern&gt;\/&lt;\/url-pattern&gt;<br \/>\n&lt;\/filter-mapping&gt;<br \/>\n<\/code><br \/>\nand you&#8217;re good.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The guys over at 37 Signals posted an explanation of why they think the Google Web Accelerator is a bad idea and a link to a page which shows how you can disable the Google Web Accelerator by analyzing HTTP headers using Ruby. I&#8217;m don&#8217;t really care to discuss why you think the GWA is &hellip; <a href=\"https:\/\/cephas.net\/blog\/2005\/05\/09\/showing-googles-web-accelerator-the-door-using-java-servletfilter\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Showing Google&#8217;s Web Accelerator the door using Java \/ ServletFilter<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/674"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=674"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/674\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}