This tip focuses on an open source toolkit provided by the Apache group through their Jakarta project. Struts is...
a Java implementation of the Model-View-Control design pattern. Simply put, Struts allows developers to build applications for the Web that can be easily maintained over time by people with varied skill sets.
In my last tip, I showed how to call the JCo connector for SAP directly through a Java Server Page. While this very quickly showed how to use JSPs to connect to SAP, the example did not demonstrate good design practice. By integrating our presentation layer (the Web page display) with our connector layer (JCo) we force our Web designers to have a high degree of Java and SAP knowledge. Moreover, in the long term, our sample application will not be able to scale with growing Internet traffic, and will eventually crash under any degree of load. So, as we develop our Web application, we need to focus on good design practices that will: a) allow the application to be maintained and supported over time and b) can grow with our needs as more and more users ramp up on the Internet. Struts represents a "best practices" framework that enables us to create an application based on proven system solutions, otherwise known as design patterns.
Check out: http://Jakarta.apache.org/struts/index.html for additional information as well as the Struts download. In coming articles, I will focus on installing Struts within the Tomcat Java application server, building a sample application, and configuring screen and workflow through standard XML interfaces.
As you review the Struts documentation a few points to keep in mind. We will be using Struts Action classes to wrapper our calls to SAP's JCo. These classes will also maintain any additional business logic, such as tying together disparate calls to SAP BAPIs and RFCs. Action classes allow us to build the bulk of our Java programming then expose these as simple interfaces to the Web developer through the Struts framework. Likewise, when you look at the XML configuration file, start thinking about what your screen flow will look like and perhaps even begin storyboarding your Web site.
In part 2 of this tip, we will install Struts within a Java application server and take a more detailed look at the components that make up Struts.
Author Austin Sincock is product manager for ROBUSTA(tm), Gamma Enterprise Technologies Web sales solution for SAP.