Thursday, October 16, 2008

Simple and very useful !!

There was a post on the Official Googleblog about fixing broken links on your page.

Eventhough this sounds very trivial, it is often forgotten.

Here is a short guide on how to use it in your (Java/J2EE/JEE) Webapplication.


  • Create your 404.jsp (copy it from the index.jsp) with the following header:     

    <%@ page language="java" isErrorPage="true" %>
  • Find the location where you want to show this Google error message.
  • Put the following code on that spot: 


    <style type="text/css"/>
    #goog-wm{}
    #goog-wm h3.closest-match{}
    #goog-wm h3.closest-match a { }
    #goog-wm h3.other-things { }
    #goog-wm ul li { }
    #goog-wm li.search-goog { display:block;}
    </style>
    <script type="text/javascript">
    var GOOG_FIXURL_LANG='nl';
    var GOOG_FIXURL_SITE='http://www.google.com';

    </script>
    <script type="text/javascript" src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>



  • Add the following code to your web.xml (the errorhandling for Java/J2EE/JEE apps in webapps)

    <error-page>
    <error-code>404</error-code>
    <location>/404.jsp</location>
    </error-page>

    <error-page>
    <exception-type>PageNotFoundException</exception-type>
    <location>/404.jsp</location>
    </error-page>







That's it. You can style it as you want, but since this is just text, it will follow your site style.

0 comments: