Google App Engine + Struts 1 example

Long live classic Struts 1 framework, in this tutorial, we will show you how to develop a Struts 1.x web application in Google App Engine (GAE) environment.

Tools and technologies used :

  1. JDK 1.6
  2. Eclipse 3.7 + Google Plugin for Eclipse
  3. Google App Engine Java SDK
  4. Struts 1.3.10
You may also interest at this Google App Engine + Struts 2 example.

This example is going to merge Struts 1.x hello world example with this GAE + Java example.

1. New Web Application Project

In Eclipse, create a new Web Application project, named as “StrutsGoogleAppEngine”.

struts1 on gae example struts1 on gae example

Google Plugin for Eclipse will generate a sample GAE project structure. later will integrate Struts 1 into this GAE structure.

2. Integrate Struts 1.x Libraries

Visit this link to download Struts 1.x. Following jars are required :

  • antlr-2.7.2.jar
  • commons-beanutils-1.8.0.jar
  • commons-chain-1.2.jar
  • commons-digester-1.8.jar
  • commons-logging-1.0.4.jar
  • commons-validator-1.3.1.jar
  • oro-2.0.8.jar
  • struts-core-1.3.10.jar
  • struts-taglib-1.3.10.jar

Copy and put it in “war/WEB-INF/lib” folder.

struts1 on gae example library struts1 on gae example library

Right click on the project folder, select “Properties“. Select “Java Build Path” -> “Libraries” tab, click “Add Jars” button and select above 9 jars from “war/WEB-INF/lib” folder into the build path.

struts1 on gae example java build struts1 on gae example java build

3. Integrate Struts 1.x Action and Form

3.1 Delete , you don’t need this.

3.2 Create a new Action class.

File : src/com/mkyong/action/

package com.mkyong.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.mkyong.form.HelloWorldForm;
public class HelloWorldAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HelloWorldForm helloWorldForm = (HelloWorldForm) form;
helloWorldForm.setMessage("Hello World!");
return mapping.findForward("success");

3.3 Create a new form class.

File : src/com/mkyong/form/

package com.mkyong.form;
import org.apache.struts.action.ActionForm;
public class HelloWorldForm extends ActionForm {
String message;
public String getMessage() {
return message;
public void setMessage(String message) {
this.message = message;

4. Integrate Struts 1.x JSP Pages

4.1 Create HelloWorld.jsp page and put in “war/User/pages/HelloWorld.jsp“.

File : HelloWorld.jsp

<%@taglib uri="" prefix="bean"%>
Google App Engine + Struts 1.x example
<h4><bean:write name="helloWorldForm" property="message" /></h4>

5. Struts XML configuration

Create a struts-config.xml file, and put it in “war/WEB-INF/struts-config.xml“.

File : struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
<form-bean name="helloWorldForm" type="com.mkyong.form.HelloWorldForm" />
<action path="/helloWorld" type="com.mkyong.action.HelloWorldAction"
<forward name="success" path="/HelloWorld.jsp" />

6. web.xml

Update web.xml, integrate Struts.

File : web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi=""


7. Enable Session in GAE

Update appengine-web.xml, enable session support, Struts need this.

File : appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="">

If you don’t enable session in GAE, you will hit error “ java.lang.RuntimeException: Session support is not enabled in appengine-web.xml“.

8. Directory Structure

Review the final directory structure.

struts1 on gae example final directory structure struts1 on gae example final directory structure

9. Run on Local

Right click on the project, run as “Web Application“.

URL : http://localhost:8888/

struts1 on gae example run on local struts1 on gae example run on local

10. Deploy on GAE

Update appengine-web.xml file, add your App Engine application ID.

File : appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="">

Select project, click on Google icon, “Deploy to App Engine“.


struts1 on gae example deploy on gae struts1 on gae example deploy on gae
Not much problem, just follow GAE directory structure, at least integrate Struts 1 is more easily than Struts 2.

Download Source Code

Due to large file size, all Struts1 jars are excluded, you need to download it manually.

Download – StrutsGoogleAppEngine (13 KB)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s