English
Skip to page content Skip to main navigation

e.g. "templates" or "datastore"

# Using Static Files

There are many cases where you want to serve static files directly to the web browser. Images, CSS stylesheets, JavaScript code, movies and Flash animations are all typically served directly to the browser. For efficiency, App Engine serves static files from separate servers than those that invoke servlets.

By default, App Engine makes all files in the WAR available as static files except JSPs and files in `WEB-INF/`. Any request for a URL whose path matches a static file serves the file directly to the browser—even if the path also matches a servlet or filter mapping. You can configure which files App Engine treats as static files using the `appengine-web.xml` file.

Let's spruce up our guest book's appearance with a CSS stylesheet. For this example, we will not change the configuration for static files. See App Configuration for more information on configuring static files and resource files.

## A Simple Stylesheet

In the directory `war/`, create a directory named `stylesheets/`. In this directory, create a file named `main.css` with the following contents:

    body {
        font-family: Verdana, Helvetica, sans-serif;
        background-color: #FFFFCC;
    }

Edit `war/guestbook.jsp` and insert the following lines just after the `<html>` line at the top:

    <html>
      <head>
        <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
      </head>

      <body>
        ...
      </body>
    </html>

Visit http://localhost:8080/. The new version uses the stylesheet.

## Next...

The time has come to reveal your finished application to the world.

Continue to Uploading Your Application.