Google App Engine enables you to build and host web apps on the same systems that power Google applications. App Engine offers fast development and deployment; simple administration, with no need to worry about hardware, patches or backups; and effortless scalability. See why you might choose Google App Engine for your next project.

Front Man™ is an implementation of the Front Controller and Command patterns that serves as an ultra-lightweight framework for quickly creating Java web applications. See the article Front Controller Java Web Applications using Front Man for more information.

For this example I used Eclipse IDE for Java Developers along with the App Engine Java software development kit. This Getting Started Guide from Google will help you set your environment up. This guide assumes you've installed the Java SDK, Eclipse IDE for Java Developers and the Google App Engine SDK.

First, create a new Web Application Project. Select File->New->Web Application Project from the Eclipse main menu. Fill in Project name, and Package, and uncheck Use Google Web Toolkit as it's not needed for this project. Click Finish to complete this step.



The previous step creates a directory structure where all your application files are stored. In my case it's D:\Documents and Settings\username\workspace\GAEFMTest. You can run this simple skeleton application from within Eclipse now if you'd like, but to use the Front Man framework two libraries are needed - The Front Man library frontman-1.6.2.jar, and the Jakarta Commons Logging library commons-logging-1.1.1.jar (note: versions may have changed from when this guide was written). Copy both libraries to the directory GAEFMTest\war\WEB-INF\lib, then from the Eclipse Package Explorer window right click on the directory GAEFMTest\war\WEB-INF\lib and select Refresh. The libraries should now be visible in the list. Right click each library and select Build Path->Add to Build Path.

Now, modify the file GAEFMTest\war\WEB-INF\web.xml to look as follows:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<servlet>  
     <servlet-name>CommandBroker</servlet-name>  
     <servlet-class>org.bibeault.frontman.CommandBroker</servlet-class>  
     <init-param>  
       <param-name>commandsPath</param-name>  
       <param-value>com.example.GAEFMTest</param-value>  
     </init-param>  
     <init-param>  
       <param-name>viewsPath</param-name>  
       <param-value>/WEB-INF</param-value>  
     </init-param>  
     <load-on-startup>1</load-on-startup>  
   </servlet>  
   
   <servlet-mapping>  
     <servlet-name>CommandBroker</servlet-name>  
     <url-pattern>/command/*</url-pattern>  
   </servlet-mapping>


	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
</web-app>


Next, create GetHelloWorldMessageCommand command class (GetHelloWorldMessageCommand.java). From within Eclipse Package Explorer right click on the folder GAEFMTest\src\com.example.GAEFMTest and select New->File. Type GetHelloWorldMessageCommand.java and click Finish.
package com.example.GAEFMTest;

import org.bibeault.frontman.*;

import javax.servlet.ServletException;
import java.io.IOException;


public class GetHelloWorldMessageCommand implements Command {
	public void execute(CommandContext commandContext) throws ServletException, IOException {
		String helloWorld= "Hello World";

		commandContext.getSession().setAttribute("helloWorldMessage",  helloWorld);		
		commandContext.forwardToView("helloWorld");  		
	}
}


Next, write the view helloWorld.jsp in GAEFMTest\war\WEB-INF.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<%@page contentType="text/html;charset=ISO-8859-1" language="java"%>
	
<html>
<HEAD></HEAD>
<body>

${helloWorldMessage}
</body>
</html>


Next, write the HTML file (GAEFMTest\war\index.jsp) with a link to call the hello world command (getHelloWorldMessage).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
	
<%@page contentType="text/html;charset=ISO-8859-1" language="java"%>

<html>
<HEAD></HEAD>
<body>

<a href='command/getHelloWorldMessage'>get hello world message.</a>
	
</body>
</html>


Finally, add <sessions-enabled>true</sessions-enabled> to the file GAEFMTest\war\WEB-INF\appengine-web.xml.
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
	<application></application>
	<version>1</version>
	
	<!-- Configure java.util.logging -->
	<system-properties>
		<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
	</system-properties>

    <sessions-enabled>true</sessions-enabled>	
</appengine-web-app>


Now, from the Eclipse IDE Package Explorer window right click on the GAEFMTest folder and select Debug As->Web Application. Point your browser to localhost:8888 and you should see your new application in action.