Welcome

Welcome to our blog about all kind of topics that are related to software development. We blog about:

SOA, BPM, EDA, ECM and all the other buzz words. Beware some post might not be so common as you think. We are not scared to go against main stream thoughts.

Technologies like java, maven, springframework, OSGi and front end technologies and frameworks like jQuery, DWR, Flex.

Finally to make this happen we need tools and of course a Mac (well some of us do). So we blog about that as well.

Archives

Serving static files in Google app engine development edition

appengine-silver-120x30.gifThere are a lot of questions about serving static files in the development edition of google app engine. There are also a few answers, but none of them gave me a clear solution. Therefore I decided to look for one myself. In the end I have created a sub-optimal solution that works for me. So maybe it can work for you as well.

Read on to find out what I did.

Google app engine uses the concept of static files. This is a performance optimization. Using the file appengine-web.xml you can configure the way google handles static files. You can include and exclude certain files using their extension or name. More information can be found here at google. This all works nice in the online version, however there seems to be a problem with the development server. Some solutions try to configure the local version as well, still that did not work for me. I decided to look for a servlet that serves static files. Yes it can be that easy.

Check the following post serving static content using a servlet. This post gives you a servlet implementation to serve static files. I used the StaticServlet.java, read the post for more information. Adding this servlet to your web.xml solves the problems in your local environment.

    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.yourscrum.web.StaticServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping> 
        <servlet-name>default</servlet-name> 
        <url-pattern>*.png,*.jpg,*.css,*.js</url-pattern> 
    </servlet-mapping>

That is it, now you can test your stuff locally and all your scripts, images, styles are loaded by your application. Of course you have to remove this servlet before uploading your application.

Hope it helps people with their local debugging of jquery scripts or other javascript things. Speaking about jquery, the next post will be about a component used for sorting items using the jquery ui component. I had an issue adding an image to the items in the sortable component.

3 comments to Serving static files in Google app engine development edition

  • K. Prins

    Sorry. index.html is:

      [head]
    	[meta http-equiv="refresh" content="0;URL=/Main" /]
      [/head]
    

    Is seems that if you don’t call an static welcome-file, the development-environment can’t find any static-file. If you do call a static welcome-file, it can find any static-file. So, calling a static welcome-file that redirects to the servlet, makes alle static-files available. This wil work in de production-environment too.

  • K. Prins

    You can make the index.html-file the welcome-file in web.xml.

    Make the content of the index.html:

    Where /Main is the url for the main-servlet.

    This wil work in the development-environment and in the production-environment.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>