Stripes - Hello, World!

Stripes is an open source web-application framework used to simplify Java web development. Stripes provides both View and Controllers of MVC architecture and let the developers to port their Model into the system. Comparing to Struts, Stripes is a lightweight and less configuration needed framework, but it provides almost everything provided by Struts. More details about Stripes can be found here.

This tutorial shows you; how to develop a simple web application using Stripes framework in Eclipse.

  • Java Development Kit 1.5 or latest
  • Eclipse JEE
  • Apache Tomcat (To add Apache Tomcat to Eclipse, follow this link.)
  • Stripes libraries and other dependencies
  • Basic knowledge in Java Servlets and JSP.
Create a new Dynamic Web Project
Step 1:
In Eclipe goto File → New → Project… and select Dynamic Web Project

Step 2:
Give the project name “Hello World” and click on Next.

Step 3:
Leave the output folder with default values and click Next.

Step 4:
Select the “Generate web.xml deployment descriptor” and click on the Finish button.

Download libraries and add them to the project
Step 5:
Download the Stripes library from this link.
Download the Apache-Commons dependency from this link.

Step 6:
Copy the downloaded JAR files to the lib folder of WEB_INF directory in your project.

Create ActionBean class
Step 7:
Create a new package under the src folder with a name: “com.javahelps.stripes.helloworld.action”.

Step 8:
Create a new class “TimeActionBean” inside that package.
package com.javahelps.stripes.helloworld.action;

import java.util.Date;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

public class TimeActionBean implements ActionBean {
 private static final String VIEW = "/WEB-INF/jsp/result.jsp";
 private ActionBeanContext context;
 private Date time;

 public ActionBeanContext getContext() {
  return this.context;

 public void setContext(ActionBeanContext ctx) {
  this.context = ctx;

 public Date getTime() {
  return this.time;

 public Resolution currentTime() {
  this.time = new Date();
  return new ForwardResolution(VIEW);
Here the ActionBean interface is used to define the TimeActionBean class as an ActionBean. At runtime, Stripes searches for ActioBean classes in a given package and use them to handle the received requests.

getContext and setContext methods are abstract methods define in the ActionBean interface, so the sub classes must override them.

currentTime is an event handler, and you can use any name for that. @DefaultHandler specifies that, any call to TimeActionBean without specifying an event name, executes the currentTime method by default.

An event handler:
  • Must have public access modifier
  • Should not take any parameters
  • Should return a Resolution
  • Should be defined inside an ActionBean
In this code currentTime method assigns the current time to the instance variable "time" and forward the request to result.jsp which is inside "/WEB-INF/jsp” folder. (Still we have not created it). result.jsp can read the time using getTime method.

Create JSP file.
Step 9:
Create a new directory “jsp” under the WEB-INF directory, and create a new result.jsp file inside that folder.

Stripes does not recommend allowing direct access to JSP files, even though it is allowed to access. This is the reason to create JSP file inside WEB-INF folder, since clients cannot directly access any resources which are inside the WEB-INF folder.

Step 10:
Modify the content of result.jsp as provided here.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri=""%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
 <h1>Current time is: ${actionBean.time}</h1>
 <s:link beanclass="com.javahelps.stripes.helloworld.action.TimeActionBean" event="currentTime">
  Update the Time
In this code, <%@taglib prefix="s" uri=""%> is used to import the Stripes library into the JSP.
<s:link> is a Stripes specific attribute which is used to create link to a given ActionBean class. The beanClass is used to provide the target ActionBean. Instead of class name, href reference also can be used as show below.
<s:link href="/Time.action" event="currentTime">
 Update the Time
However, using the actionBean with class name is recommend, because it clearly shows that which class is going to handle the request.
The event is the method name which is declared in the TimeActionBean class.

JSP uses an ${actionBean.time} expression language; the actionBean is a reference to the TimeActionBean which will be assigned by the ActionBean when it forwards the request to JSP. ${actionBean.time} gets the assigned time and display it in the page.

Configure The Stripes Framework
Step 11:
Open the web.xml and replace its content by this code.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
 id="WebApp_ID" version="3.0">
 <display-name>Hello World</display-name>



Deployment descriptor of the web application is used to configure the Stripes framework. The filter's  init-param value of ActionResolver.Packages is the package where Stripes searches for ActionBean classes. In this project the ActionBean class TimeActionBean is inside the com.javahelps.stripes.helloworl.action package which is provided as the param-value. <welcome-file> uses the TimeActionBean as the welcome file.

URL of an ActionBean class is determined from the class name according to the following rules.

1. Start with the fully qualified class name of the action bean.
2. Remove the package prefix up to and including any of the following package names: action, stripes, web, or www.
3. If present, remove the class name suffix Action, Bean, or ActionBean.
4. Convert the package and class name to a path by prefixing with a forward slash and changing all periods to forward slashes.
5. Append the .action suffix.

Step 12:
Right click on the project and select Run As → Run on Server. Select Tomcat server and click next.

Step 13:
Make sure the application is listed under Configured applications and click on the Finish button.

Step 14:
Click on the “Update the Time” link and see the output.

Find the project at Git Hub.
Next Post »

Contact Form


Email *

Message *