NetUI Page Flows: An Evolution of Struts

by Srinivas Jaini


Struts is a popular framework used to build enterprise-level J2EE applications. With Struts, J2EE Web application development has become easier and more manageable. Beehive, an open-source project by the Apache Software Foundation, goes to great lengths to make Web application development even more straightforward by building a simple Page Flow model on top of Struts. Using the new JSR-175 and JSR-181 metadata annotation facilities, Beehive reduces the coding necessary for J2EE application development. This article introduces the Beehive Page Flow technology, and looks at how you can use it to increase the productivity and quality of Struts software. It also examines how you can migrate to include this technology in a vanilla Struts application. The article assumes you have some familiarity with Struts.

Vanilla Struts

Struts, a part of the Jakarta project by the Apache Software Foundation, is an open-source framework for building Web applications based on the Model-View-Controller (MVC) design pattern. Struts uses action classes to build the controller component of a framework. A typical Struts application requires a number of action classes to handle several actions of a process flow and also an XML configuration file to declare forwards. Therefore, issues like data management and maintenance have become a major concern in existing Struts applications. Figure 1 shows a flow view of a sample application devised to make a comparative study between Struts and Page Flows.

Figure 1
Figure 1. Flow view of the LoginProcessFlow application

This application, when developed in Struts, typically will require action classes for each of the actions begin, signup, login, and logout. Listing 1 shows a typical Action class, in this case the begin action depicted in the diagram.

Listing 1.

package comparision.struts;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public final class BeginAction extends Action {


    public ActionForward execute(ActionMapping mapping,

                                 ActionForm form,

                                 HttpServletRequest request,

                                 HttpServletResponse response)

        throws Exception {


        return (mapping.findForward("success"));



Similar action classes for signup, login, and logout are required to complete the Struts application. The HTTP session is used to pass data across actions, making it cumbersome to manage and maintain data. Struts uses a configuration file, struts-config.xml, to declare forwards to JSP pages. So a business rule change typically requires changes to be made across action classes and the configuration file. In particular, business logic changes require changes to be made in action classes, and changes in flow require changes in the configuration file (changes often require a combination of both). Listing 2 shows a typical struts-config.xml file for the LoginProcessFlow application.

Listing 2. struts-config.xml

<!DOCTYPE struts-config PUBLIC

 "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"

 "" >


    <!-- Form Bean Definitions -->


       <form-bean name="UserForm" type="Samples.Struts.UserForm"/> 


    <!--  Action Mapping Definitions  -->


        <action path="/Startup" 



          <forward name="login" path="/index.jsp"/>



        <action path="/LoginForm" forward="/mypage.jsp"/>

        <action path="/login"











    <!-- message resources -->



        null="false" />


Pages: 1, 2, 3, 4, 5

Next Page ยป