This post is a tutorial / list to make a Google AppEngine Java web application serve static files (html, js, css)

Check out the google’s sample code or download the code

git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git

Or Download Link for master.zip

The baseline for this tutorial is in java-docs-samples/appengine/helloworld

cd java-docs-samples/appengine/helloworld

Map the static configuration for AppEngine

Edit appengine-web.xml:

vim src/main/webapp/WEB-INF/appengine-web.xml

Then add

<public-root>/static</public-root>

add folder static in WEB-INF

mkdir src/main/webapp/WEB-INF/static

Add welcome-file

vim src/main/webapp/WEB-INF/web.xml
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

Add a index.html

touch src/main/webapp/WEB-INF/index.html

Edit it and add:

<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
</head>
<body>

<h1>This is a Heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

Start the devserver


gradle appengineRun

or


mvn appengine:devserver

Then check it on your browser: link to localhost

Check the sample code here

Link Here