Services | Updates | Contact
Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML

Send Redirect in Servlet
When we want that someone else should handle the response of our servlet, then there we should use sendRedirect() method
 
Fat Jar Eclipse Plug-In
The Fat Jar Eclipse Plug-In is a Deployment-Tool which deploys an Eclipse java-project into one executable jar.
 
More Tutorials...

Search All Tutorial
Top Search: Loan Struts Open Source

Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

 
 
Struts

 
Comments
 
 

 

Struts Articles

Building on Struts for Java 5 Users
Struts is undoubtedly the most successful Java web development framework. It is the first widely adopted Model View Controller (MVC) framework, and has proven itself in thousands of projects. Struts was ground-breaking when it was introduced, but the web development landscape has changed a lot in the last few years. It is also fair to say that Struts is not universally popular, and has in many ways been overtaken by other frameworks. 

Strecks is built on the existing Struts 1.2 code base, adding a range of productivity enhancing features, including:

  • pure POJO actions
  • action dependency injection
  • action controllers encapsulating request workflow
  • action interceptors
  • form validation using annotations
  • data conversion and binding using annotations
  • pluggable navigation

How to Create Secure Web Applications with Struts
This article will focus on developing secure Web applications with the popular Java framework Struts. It will detail a set of best practices using the included security mechanisms. The first section will provide an overview of both Struts and Web application security as a context for discussion. Each subsequent section will focus on a specific security principle and discuss how Struts can be leveraged to address it.

Struts is a very popular framework for Java Web applications large and small because of the numerous advantages it offers developers. The main goal of the Struts framework is to enforce a MVC-style (Model-View-Controller) architecture, which means that there is a separation of concerns among different architectural components: the model is the representation of the logic, the view is in charge of displaying data to the user, and the controller is responsible for providing the user with a way to interact with the application and affect the model. A simple analogy for this is a video game, where you have a game console (the model), the television or monitor (the view), and a controller (quite appropriately, the controller). This architectural pattern promotes reuse and stability by reducing the effects of code changes (since the implementation of each component is agnostic to the implementation of the others and the model is isolated from the user).

Bridge the gap between Struts and Hibernate
Hibernate and Struts are currently among the most popular open source libraries on the market. Effectively, they are the default developer selections among competing libraries when building Java enterprise applications. Although they are often used in conjunction with one another, Hibernate was not primarily designed to be used with Struts, and Struts was released years before the birth of Hibernate. To put them to work together, some challenges remain. This article identifies some of the gaps between Struts and Hibernate, particularly related to object-oriented modeling. It also describes a solution for bridging these gaps that involves an extension to the Struts framework. All Web applications built upon Struts and Hibernate can derive benefit from this generic extension.

Scheduling Jobs in a Java Web Application
There is a robust open source solution that works like a charm to standardize the way you conduct scheduling in a web application (or any other Java application, for that matter). The following examples will show you how to use Quartz, an open source scheduling library, to create a scheduling framework in your web application. The example also uses Struts Action framework plugins in order to initialize the scheduling mechanism when the web application starts. The Struts Action framework (or just "Struts") is a such a common framework that it should be familiar for most developers. Of course, there are many other frameworks available for Java web applications that facilitate a Model-View-Controller design pattern.

The first thing we want to do is set up the Struts plugin to create our scheduler when the container starts. For these examples, it is assumed that Tomcat will be the web application container of choice, but the examples should work in any container. We will create a Struts plugin class and add some lines to the struts-config.xml file to get this going.

Development Standards in Apache Struts
Apache Struts is a great framework for developing the front-end of Web applications. With smaller apps, it's hardly worthwhile to setup precise standards for how to define action classes and flow. However, the issue of standardization becomes more important as an application grows more complex. This is especially true when there are more developers on a team—then standardization becomes crucial. Most of the functionality in Struts can be implemented in many ways using Struts and having many developers working on the same project without standards will inevitable lead to an non-homogeneous and difficult to maintain system.

If you're an experienced Struts developer looking for ways to standardize a Struts application architecture, this article offers several pieces of advice to help improve development speed and the quality of your applications. 

Struts Validations Framework Using AJAX
The validation framework is used to validate fields. There are many ways to do validation on a Web application. It falls into two categories: server-side and client-side. A struts validation framework is one of the best frameworks for a Java-based Web application environment. It can configure the application using server-side validation and employ the error message that renders on the validation process invoked during the request processing time, or it can do client-side validation by using the JavaScript rendered on the requested page.

This article is concerned with enriching the existing struts validation framework with AJAX. A few components, such as a controller, have to be developed to select the validation framework and render the specific format message for the client side and a taglib to handle the error message rendering.

Developing JSR168 Struts portlets: Part 2. Enhancing the portlet
The first part of this article series showed developers who are familiar with the Struts framework in the servlet environment how to use Struts in the WebSphere Portal environment. We created a simple portlet application and then applied features of the Tiles and Validation frameworks to the application. In this part, we look at some portlet specific features provided by the IBM Struts Portlet Framework 5.1.0.1 (hereafter called the framework).

Portlets differ from servlets in several ways so the framework includes support beyond the servlet Struts framework. In Part 1, we talked about how it supports additional request processing requirements using the IViewCommand interface. Now you look at some of the additional support provided by the framework; specifically, you see how to use support for modes, devices, internationalization, and creating URLs, as well as how to integrate with the property broker so you can use cooperative portlet capabilities (a capability not yet available through the JSR 168 API).

An Exception Handling Framework for J2EE Applications
In most Java projects, a large percentage of the code is boilerplate code. Exception handling comes under this category. Even though the business logic may be just three or four lines of code, exception handling might go on for ten to 20 lines. This article talks about how to keep exception handling simple and straightforward, keeping the developer's plate clean for him to concentrate on business logic rather than devoting time to writing exception-handling boilerplate code. It also gives the basis and guidelines to create and deal with exceptions in the J2EE environment and targets some of the business problems, in which exceptions could be used to resolve them. This article uses the Struts framework as the presentation implementation, though the approach is applicable to any presentation implementation.

Developing JSR168 Struts portlets: Part 1. Creating a simple portlet
This article steps you through how to develop a simple JSR 168 compliant Struts portlet. You discover how request processing differs in the portlet Struts environment from the servlet Struts environment. You also see how to use the IViewCommand interface, and how to use popular Struts features, such as the Validation Plug-In and Tiles Plug-In, to enhance the basic portlet.

This article is not intended to be an introduction to either Struts or JSR 168. It assumes you have some experience using Struts in a Servlet environment and that you want to take advantage of this knowledge in a portlet environment. It can also be of interest to developers who already know how to use Struts to develop IBM Portal API compliant portlets. If you are new to either Struts or portlet technology, then please take a look at the Resources section for links to references which can help you get that background.

How to Make Struts People Happy with JSF
As a big promoter of JSF, I have been doomed to deal with many people, who have previous Struts experience. I notice in many cases that some sort of “paradigm mismatch” exists between Struts and JSF. I call this the “problem of the locomotive and the train.” Basically, this is a question of where to put the train engine – at the head or at the end of the train.

The usual sequence of events looks like this:

1. Struts Servlet receives the call for “/show-me-something.do”, recognizing the call based on the action mapping definitions in the struts-config file.
2. Servlet creates (or reuses existing) Form Bean.
3. Servlet calls the appropriate Struts Action execute() method, passing a Form bean among the parameters.
4. A Struts Action does the job, may be calling some other tiers of the Application Stack, maybe filling a Form Bean with some useful data.
5. The Struts Action returns a specific strongly-typed Action Mapping instance to let the Servlet know what page has to be rendered
6. The Servlet calls forward() to render that Page
7. During rendering, the Page can access some data in a Form Bean using special tag libraries (usually ether Struts, or JSTL)

Open Source-Based Portal-Lite
In the case of building a Proof Of Concept (POC) for a portal, you can solve all of the above by using the Open Source Apache Struts running on Jakarta Tomcat. With only a few lines of code and minor modifications, you can build a demo portal that can be run on a laptop by anyone who knows how to click an icon.

The key to the POC portal is in leveraging Struts Tiles. Portals are, in essence, a set of consistent layouts with different components. Struts Tiles are a continuation (seems like a replacement, now) of Struts Templates. Tiles leverage the JSP include feature to facilitate the reuse of presentation components in a consistent manner. Having built many portals as a consultant, the first time I saw a Tiles example (in someone else's online article for which I have lost the URL), I thought, "That is a portal."

Succeeding with Struts: Dynamically Allocated Forms
The peril of ending an article with a item left as a problem for the reader is that it inevitably comes back to haunt you. In my last article, Succeeding With Struts: Dynamically Sized Forms, I mentioned casually that it was possible to set up a form with indexed properties such that it could have a dynamically initialized array of values that varied depending on the number of items submitted. And, of course, I've gotten a ton of letters since then asking exactly how to go about it.

The classic example of this type of problem is a checkout form for a shopping cart. The action that displays the form knows exactly how many items are in the cart, and therefore can create the appropriate size array to service the page. But what happens when you submit? Remember that form populate happens very early in the Struts request processor, before validation or action processing. Even if you wrote a magic hidden field with the number of lines on the page, how could you get the array allocated before the form was populated, because the action runs after the form is populated? The answer lies in the one thing that does run before form population, the reset method for the ActionForm.

Support Eastern Languages in Your Struts Web Applications
Many Web development frameworks provide i18n support for this purpose. The Struts framework, one of the most commonly used, is no exception. Struts provides a set of classes and JSP tags that make it easier to work with i18n. This infrastructure enables Struts developers to produce multi-language applications with minimal extra effort and time.

Despite Struts' excellent i18n support, however, Struts applications that need to use Eastern languages such as Arabic require special attention and extra work. This article demonstrates how to build a Struts Web application that runs in English and Arabic. You will see how to set the user locale in Struts Action classes, set the appropriate HTML page direction, select the appropriate Cascade Style Sheet (CSS) file, and convert properties files so that Arabic characters are displayed correctly. 

Dynamic radio buttons with Struts
This recipe follows on the heels of what you learned in my last article, "Dynamic checkboxes with Struts." Like dynamic checkboxes, radio buttons with dynamically selected elements can add a lot of sophistication to your Web pages, and with Struts, they're also easy to create.

In this article, I show you how to create a radio button group by nesting the Struts tags <logic:iterate/> and <html:radio/>. I then reference a specified form bean to the tags and iterate through a String[] array of radio button values, assigning an identical name attribute to each assigned value attribute.

What Is Struts
Apache Struts is an open source Java framework used for building web applications based on the servlet and JavaServer Pages (JSP) technologies. Is it conceivable that anyone in the business of building software hasn't heard of the Struts framework? From developers that are just starting out in the business to those long in the tooth, the name "Struts" surely must ring a bell. But if you haven't spent your development time in the Java world or haven't had the need to build web applications, Struts might only be a buzzword that you've added to your resume. For the next five to ten minutes, you're going to be taken on a whirlwind tour of the Struts framework. Get a drink (non-alcoholic, of course), sit back, and put your feet up, and learn a little about one of the most popular free frameworks to ever grace the open source community.

Build extra secure Web applications
You can easily integrate the protection framework with the Struts tag library so that the framework implementation is transparent. To integrate the framework into Struts, you must inherit the Struts tag libraries.

To protect form action and hidden fields, you modify Struts' FormTag and HiddenTag to invoke the Processor. Create a subclass that:

1. Extends Struts HiddenTag class; collects all hidden field parameters and stores them into the pageContext attribute.
2. Extends Struts FormTag class; overrides doAfterBody method to register the pageContext attribute and form action with Processor. The returned reference code outputs as a hidden field.

Sprinkle Some AJAX Magic in Your Struts Web Application
AJAX is the latest revolution in web development circles, allowing rich dynamic interfaces deployed within a normal web browser. Struts has been one of the de facto standards for Java-Web development for a number of years, with a large number of applications already deployed. This article will show you how to combine the richness of an AJAX user interface with your existing Struts applications.

The chances are that if you are reading this article, then you are interested in AJAX's ability to create dynamic web interfaces and would like to know how to add it to a Struts application. What are your options if you want to do this?

1. Wait until the next version of Struts (Shale) incorporates AJAX techniques. For Struts developers starting a new application this is probably the best option. The downside is that this will probably require moving to JavaServer Faces--not a bad thing in itself, but this may entail fundamental changes if you have an existing application.
2. You could move to a new approach, like Direct Web Remoting (DWR) or Ruby on Rails, which are specifically built for AJAX applications. While these are both very impressive frameworks, and are worth taking a look at if you wish to consider web development without Struts, this option would mean rewriting your entire application.
3. Add AJAX to your existing Struts application. Since AJAX is a technique, not a framework, it is straightforward to add it to Struts. For existing applications where stability (e.g., keeping existing libraries) is important, this option is recommended and is the one we explore in more detail.

Test-Driven Development Using StrutsTestCase
StrutsTestCase is a powerful and easy-to-use testing framework for Struts actions. Using Struts and then StrutsTestCase, in combination with traditional JUnit tests, will give you a very high level of test coverage and increase your product reliability accordingly.

StrutsTestCase is a test framework based on JUnit for testing Struts actions. If you use Struts, it can provide an easy and efficient manner for testing the Struts action classes of your application. The StrutsTestCase project provides a flexible and convenient way to test Struts actions from within the JUnit framework. It lets you do white-box testing on your Struts actions by setting up request parameters and checking the resulting Request or Session state after the action has been called.

StrutsTestCase allows either a mock-testing approach, where the framework simulates the web server container, or an in-container approach, where the Cactus framework is used to run the tests from within the server container (for example, Tomcat). In general, I prefer the mock-testing approach because it is more lightweight and runs faster, and thus allows a tighter development cycle.

Dynamic checkboxes with Struts
In user interface design, the checkbox group isn't as popular as its cousin, the multi-line selectbox. They both basically do the same thing; that is, they choose a collection of options mapped to a single name attribute. When used in groups, checkboxes actually perform the same function as the multi-line selectboxes, but they take up a little more screen real estate. This can be beneficial when you want the user to be able to view all the choices before selecting one or several of them.

While the multi-line selectbox typically provides a better look and feel when the choices are limited, a group of checkboxes is the better choice for any enterprise application where selection boxes must be rendered dynamically and contain preselection functionality. Fortunately, creating a group of dynamic checkboxes is easy to do with the Struts framework.

Get a better handle on Struts actions, with Spring
Like Struts, Spring can also function as an MVC implementation. Both frameworks have their merits and drawbacks, although most would agree that Struts is still king when it comes to MVC. Many development teams have learned to rely on Struts as the foundation for building quality software under strict deadlines. With so much momentum behind Struts, even development teams that would like to integrate features of the Spring framework don't want to switch to Spring MVC. The good news is that you don't have to. The Spring architecture allows you to connect Struts as your Web framework to Spring-based business and persistence layers. The end result is that you can have your cake and eat it too!

In the recipes that follow, you'll learn three ways to integrate Struts MVC into the Spring framework. I'll expose the cons of each recipe as well as its comparative advantages. Once you've seen all three in action, I'll show you an exciting application of the approach I like best.

Apache Struts Framework: The Big Picture
In this article, I will describe how to work with Struts, go over its main features, and discuss setting it up in an enterprise development environment. 

The Struts framework is an open-source product for building Web applications based on the model-view-controller (MVC) design paradigm. It uses and extends the Java Servlet API and was originally created by Craig McClanahan. Please note: Because of the extensiveness of the Struts framework, there are entire books written just about it. It will be impossible to describe all the features of the framework in the constraints of this article. However, I will talk about the most important aspects of the framework. Also, I am assuming that you are familiar with some enterprise Integrated Development Environment (IDE), such as JBuilder 2005 or Eclipse and know how to create a Web application with it.

Struts-Velocity integration
In this article, I'll show you how to integrate and use the Velocity Template Engine in your Struts applications. I'll give you the formula up front and then walk you through it, step-by-step. The resulting application will be one that combines Struts and Velocity -- a stellar combination that just might make you question your loyalty to JSP!

The recipe for combining Struts and the Velocity Template Engine is simple and straightforward; in fact, you can do it in just five steps:-
1. Place the Velocity JARs in your classpath.
2. Modify the web.xml file to recognize the Velocity servlet.
3. Place the Velocity toolbox.xml under your application's WEB-INF directory.
4. Modify your struts-config to point its views to Velocity templates instead of JSPs.
5. Create a Velocity template for each page you want to render.

Spring Your Struts Apps Ahead: The Struts-to-Spring Migration
This article helps developers who want to migrate their Struts applications to Spring MVC understand the logical mapping between the two frameworks and how to transform Struts applications into Spring MVC applications. Application developers with good Struts skills also will learn how key Struts concepts relate to Spring MVC concepts. Finally, this article should help architects understand and estimate the migration paths from Struts to Spring. To fully appreciate the subjects discussed, readers should have a working knowledge of the Struts framework.

The article is divided into two main parts:-
1. Logical mapping between the basic concepts of the Struts and Spring MVC frameworks
2. Essential recommendations for migration alternatives

Data Retention in JSPs using Struts
This article is intended for developers who have some working knowledge in the struts framework. The content of the whole article is purely based on what we have learned from our work experience.

Retaining data is one of the typical problems that a developer faces even after working in web applications for a considerable amount of time. Mostly we face such problem when some validation error happens through jsp, or user is submitting to the same jsp (or action path). The complexity lies in the fact that all of the fields that we need to retain are in the jsps, whether it is an array of html fields or just simple html fields.

Upload Files with Struts, Store Them with Hibernate
This article explains all the bottlenecks involved in this task and provides functional, easy code, which you will be able to use in your own projects. Struts 1.2.4 is used as the framework for building Java Web applications and Hibernate 3.0 (RC1) is used as the object/relational persistence and query service.
The article was written using Windows. On other operation systems, everything should run with only minor changes (if any at all).

Familiarity with BEA WebLogic server and of course with developing J2EE applications using Struts and Hibernate is necessary.

NetUI Page Flows: An Evolution of Struts
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.

First Steps With Jakarta Struts, Part 2
Last time we looked at Jakarta Struts, I explained the persistence and business object layers and we wrote code to retrieve the list of topics from the database and represent them as objects. We used a Struts ActionMapping and an ActionForward, to get as far as the JSP that will actually display the topics on the screen.

Struts comes with a bean taglib, that provides JavaBeans-related functionality and an html taglib that renders common HTML attributes and JavaScript event handlers. Both are used within topics.jsp, as is the logic taglib mentioned last time.

Improve performance by caching Struts and Tiles applications
Struts is an open source framework for building Web applications based on the model-view-controller (MVC) architecture. The Struts framework provides its own controller component and integrates with other technologies to provide the model and the view. The primary focus of this framework is to provide a control layer for the Web application, reducing both construction time and maintenance costs.

The Tiles framework builds on the jsp:include feature of Java™ Server Pages (JSP) architecture, and comes bundled with the Struts Web application framework. This framework helps to reduce the duplication between JSP files, as well as make layouts flexible and easy to maintain. The Tiles structure provides a full-featured, robust framework for assembling presentation pages from component parts.

Create an XML Web Application with Struts, Xerces, and Xalan
Despite XML's ubiquity, it's not always obvious how to use it in a Web application—or why you would want to in the first place. This article answers both questions, explaining why and how to build a simple XML-oriented Web applicationIt will help for you to already be familiar with XML, Java's XML API, and of course, with creating of J2EE Web applications using the Jakarta Struts framework. However, even if you're not proficient with the above-mentioned tools, this article can certainly serve as your starting point.

For your Web container, you can use any J2EE compliant server—this article uses JBoss 3.2.6. To build the Web application, use the open source framework Jakarta Struts 1.2.4. For XML/XSLT processing, you'll need Apache Xalan 2.6.0, which is an XSLT processor for transforming XML documents into HTML, text, or other XML document types. To create XML documents, you'll need Apache Xerces2, but you do not need to download and install it separately, since it's included in Xalan's package. To compile, pack, and deploy, you'll need the Apache Ant 1.6.2 build tool.

First Steps with Jakarta Struts
this article isn't an attempt to provide a definitive source of documentation. Rather, it's intended to allow Struts newcomers to hit the ground running, to get a feel for what the framework is like, and understand what it can and can't do.

Of the Struts example applications I've seen, most have been either too trivial or too complex, the complex ones having lots of external dependencies that must be resolved before the example can even be compiled and run. In this tutorial, I'll attempt to hit a spot between these two extremes. I've deliberately created an application that has the minimum of external dependencies, so you should be able to actually run the code without too much difficulty! Everything you'll need is open-source and can be downloaded for free -- one of the advantages of J2EE.

Web Wizard Component, Part 2: The View
I will show how to create the wizard user interface using the Struts framework. I chose it primarily because I've used it for quite a while, and I know it well. Struts is widely adopted by the Java community, so the source code should be easy to understand. I also believe that front controller paradigm, used in Struts and the like, allows for better exploitation of the underlying HTTP protocol. On the other hand, most of the code is Struts-agnostic, and can be ported to other frameworks with a similar programming model.

The complete wizard will contain the following components:-

1. The Rule Container, which consists of the wizard controller, nodes, and edges. We designed this component in the previous article.
2. Three wizard pages, corresponding to the three nodes of the Rule Container.
3. Two stub pages, which are used when the Rule Container is not initialized.
4. The UI controller, defined by Struts' action class/form bean classes.

Web Wizard Component, Part 1: The Model
This article makes another approach to complex control elements for the Web, and shows how to implement a wizard control using the good old <form> element on the client side and a set of navigation rules on the server side. The navigation rules are fully detached from the user interface, providing better code reuse and allowing the testing of wizard rules programmatically.

A wizard is a UI component, designed to input data in portions step by step. A wizard usually has the following qualities:
1. All wizard data compose a single transaction.
2. Steps are processed in sequence from beginning to end.
3. There is one starting step, several intermediate steps, and one ending step.
4. The wizard validates its state before advancing to the next step.
5. There can be several different paths to reach the ending step.
6. It is possible to navigate back to review and update values entered in previous steps.
7. A wizard can be cancelled before completion.

Audit Your Struts Configuration Files to Avoid JAAS Errors
The Struts Web application framework facilitates building robust Web applications. Java Authentication and Authorization Services (JAAS) is a rich API for adding pluggable security modules to applications. These powerful services work well together, however, their combination can also add some complexity to maintenance and enhancement tasks. Maintaining synchronization between an application's Struts configuration file(s) mappings and the JAAS security framework policy file can be a challenge.

The Struts configuration files are XML and the JAAS policy file is a structured text file, therefore, they can be parsed and processed in an automated fashion. This article describes an audit utility that iterates over the XML configuration files in a given directory, parses the <path> element and then verifies that the path element data (the page file name) appears in the JAAS policy file. This article walks you through the Python code for the utility so you'll be able to customize it for your environment. The article doesn't discuss how to use Struts or JAAS; if you're not familiar with these technologies you should explore the resource links listed in the left column of this article.

The Best of Both Worlds: Integrating JSF with Struts in Your J2EE Applications
Struts has been a popular and widely used framework for building web applications using Java. Recently, a new API that has significant overlap with Struts functionality—JavaServer Faces (JSF)—has become standard, giving rise to questions about which technology developers should use, and what they can do with existing Struts-based applications to start taking advantage of JSF's capabilities. This article briefly introduces both technologies, and discusses how to migrate the user-interface elements from Struts to JSF, providing a technique you can use to integrate the two technologies to obtain the best of both worlds.

The Struts Framework is a very popular framework for building web applications in Java. Its key features include:

1. An overall architecture based on Model-View-Controller (MVC) design principles in which all requests get funneled through a controller that exerts overall management and dispatches requests to appropriate application components as needed, based on logical identifiers that reduce coupling between tiers.

2. Form-management capabilities, such as the ActionForm JavaBean that represents the server side state of the input fields on a form, and a validation framework externaliz the configuration of the set of correctness checks to be applied to input field values, plus implement those checks on both the client side and the server side.

3. The Tiles framework for layout management, which supports creation of sophisticated layout templates that can be reused across multiple pages, and thus allows easy modifications to the overall look and feel of an application.

4. A set of JSP custom tags that can simplify the process of creating the application's HTML markup for the view tier of your application, and which works in a synergistic way with the form management capabilities and the overall controller architecture.

Struts action mappings: Divide Et Impera
This article discusses different combinations of a Struts action class and a form bean and how these combinations can be used.

Full action call sequence

1. Struts controller component receives a request.
2. Struts identifies the action mapping which is responsible for request processing.
3. Struts creates a new instance of the form bean, if it was not found in the scope or if the scope has "request" type. If the bean exists in the scope, it is reused.
4. If form bean defines reset() method, it is called (1)
5. Struts populates the fields with request arguments, using mutators (2)
6. Struts calls validate() method if "validate" attribute of action mapping is not set to "false" (3)
7. If validate() returns non-empty ActionErrors object, control is forwarded to an URI identified by "input" attribute of the action mapping (4a)
8. if validate() returns empty ActionErrors object or null, Struts calls execute() method of the action class (4b)
9. execute() method returns an ActionForward object, which is used by Struts to select the destination URI (5)

Struts Best Practices
Struts is a popular Web presentation framework that has garnered considerable community support. This article aims to highlight some best practices that can be applied in medium to large projects to aid efficient development and low-maintenance quality code. In the course of this article we shall explore ways to optimize the design and development of Struts-based applications.

Struts, a Jakarta project hosted by Apache, is a framework for building Web applications based on the MVC2 design pattern. The framework, built upon standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, aims to provide an extensible Web application architecture that the development team can build on. The use of Struts enforces modularity and separation of concern, increases code manageablity, extensibility, and consistency.

Error validation and exception handling in portlets, using the Struts Portlet Framework
Having a good design and implementation for error validation and exception handling enables applications to respond gracefully in abnormal conditions. This article tells how you can leverage error validation and exception handling features, which are built into the WebSphere Portal Struts Portlet Framework, in your portlet applications.

Most portlet applications accept input from users. The input can come in many forms, such as input text fields, dropdown lists, radio buttons, or check boxes. Sometimes users do not provide appropriate input. An application might expect specific date and phone number formats, require certain input fields, and need other specific forms of data. Therefore, the application needs to validate the input.

Extending Struts
In this article, we will use a sample Struts application to demonstrate how to extend Struts using each of these three approaches. Downloadable sample code for each is available below in the Resources section at the end of this article. Two of the most successful examples of Struts extensions are the Struts Validation framework and the Tiles framework.

Struts is not only a very powerful framework, but also very extensible. You can extend Struts in three ways:

1. PlugIn: Create your own PlugIn class if you want to execute some business logic at application startup or shutdown.
2. RequestProcessor: Create your own RequestProcessor if you want to execute some business logic at a particular point during the request-processing phase. For example, you might extend RequestProcessor to check that the user is logged in and he has one of the roles to execute a particular action before executing every request.
3. ActionServlet: You can extend the ActionServlet class if you want to execute your business logic at either application startup or shutdown, or during request processing. But you should use it only in cases where neither PlugIn nor RequestProcessor is able to fulfill your requirement.

JavaServer Faces (JSF) vs Struts
I would have to say, the most common question or feedback came along the lines of comparing Struts to JSF. I thought it would be a good idea to compare JSF to Struts by evaluating various features that an application architect would look for in a Web application framework. This article will compare specific features.

In general, JSF is a much more flexible framework, but this is no accident. Struts is a sturdy framework and works well. JSF was actually able to learn a great deal from Struts projects. I see JSF becoming a dominant framework because of its flexible controller and navigation. Furthermore, JSF is built with integration and extensibility in mind. If you are starting a new project today, you'd have to consider many factors. If you have an aggressive schedule with not much time to deal with evaluating different vendors or dealing with support for new JSF implementations, Struts may be the way to go. But from a strategic direction and programming model, JSF should be the target of new applications. I encourage developers to take time to learn JSF and begin using them for new projects. In addition, I would consider choosing JSF vendors based on component set and RAD tools. JSF isn't easier than Struts when developing by hand, but using a RAD JSF tool like WebSphere Studio can greatly increase your productivity.

Solving the logout problem properly and elegantly
This article presents solutions for properly handling the logout problem along with sample programs. Author Kevin Le starts by describing an ideal password-protected Web application. He then uses sample programs to illustrate how the problems manifest themselves and discusses the solutions required to fix the problems. By centering the discussion on JavaServer Pages (JSP), the article presents the concepts that can be easily understood and adopted for other Web-tier technologies. Le concludes his discussion by showing how building Web applications with Jakarta Struts can more elegantly solve the logout problem. Sample programs for both JSP and Struts Web applications are included.

Unit Test Your Struts Application
This article introduces StrutsUT, a simple extension to the Cactus framework, to help solve this problem. It provides two solutions to unit test Struts applications: a "traditional" solution and one based on AspectJ. Developers can choose either for their convenience.

This article explains the initial idea of Cactus from a developer's point of view and extends this idea further into the Struts domain, which is the core of StrutsUT. The reader should have some knowledge of and experience in Struts framework, JUnit, Cactus, and/or AspectJ.

JUnit is a framework to create and perform unit tests on Java classes. With the help of mock objects and override technology, JUnit can perform unit tests for most Java applications. See References below to learn more about JUnit and mock objects. In this article, I chose EasyMock as the mock object implementation.

Struts best practices
The primary sources of information for this article are the Struts users' mailing list, the Struts developers' mailing list, and my experience with Struts-based applications.

The article discusses the following main points:

1. Screens with dynamic fields
2. Safeguarding JSP pages
3. Error categorization
4. Validation of service requester
5. Application security
6. Prepopulation
7. Stack maintenance (for bread crumbs)
8. Context-related problems
9. Form-bean scope
10. Data transfer object implementation
11. Exceptions
12. Action chaining

Web app security using Struts, servlet filters, and custom taglibs
In this article, you have developed a powerful Web-based security architecture that is flexible enough to cater to a wide range of Web-based applications. You have also leveraged existing technologies such as Struts, which have helped maintain a clean separation of security and presentation code. You can also plug the security model into any existing application; it works well with third-party authentication providers.

Attribute-level security, although a useful feature in most applications, is often ignored because of the effort involved in its implementation and the degrading effect it has on application performance. The architecture defined in this article makes it easy to implement this useful feature without compromising on performance. The architecture also helps you maintain a clean separation between the security requirements and the functional requirements of the application. You, as the application developer, can concentrate on developing the business functionality without worrying about the security aspects, and your application is easier to maintain. 

Rapid Struts Development
This article shows how Oracle JDeveloper 10g can help you automate a lot of Struts tasks and develop Struts applications. It details the development of a sample Struts application that demonstrates the usage of various Oracle JDeveloper 10g tools, such as the new Struts flow diagram.

One of the most useful features of Oracle JDeveloper 10g is the Struts flow diagram. Struts does a great job of managing flows in the application, but understanding these flows by looking through an XML configuration file can be quite difficult. With the Struts flow diagram, you can now easily depict, in just one diagram, all the flows in a system. The interactive nature of the diagram means that you can also make changes and additions to the application from within the diagram.

Reuse Tiles and Simplify UI
The Tiles framework was created to address this limitation and to enhance the Struts framework. Tiles extends the concept of reuse via includes by allowing you to define layouts (or templates) and then specify how the layouts are populated with content.

Now that you've seen the benefits of using the Tiles framework, here are the steps necessary for adding Tiles to your Struts application:

1. Add the Tiles Tag Library Descriptor (TLD) file to the application.
2. Create layout JSPs.
3. Update existing JSPs to use layouts.
4. Create a tiles-defs.xml file.
5. Update forward definitions in and add the Tiles plug-in to the struts-config.xml file.
6. Repackage and run the updated application.

A Practical Guide for Integrating EJB and Struts
You'll find plenty written about building and deploying EJB, and perhaps equally as much about building applications with the Struts framework. But what about leveraging EJB and Struts together? This tutorial lays out a complete step-by-step guide to integrating these two technologies, developing EJB components and incorporating them into Struts.

Now you are ready to modify your project properties:

1. Right click on your project StrutsEJBTutorial in the package explorer of Eclipse.
2. Select properties, and Click Java Build Path.
3. Modify your source folder. For this tutorial, keep intact the directory structure of a Struts project. Click StrutsEJBTutorial and click Add Folder. Expand the WEB-INF node, then expand the src node, check java, and click OK. Make sure that WEB-INF and src are not checked; otherwise, Eclipse will try to recognize these as source folders as well.
4. Modify your output folder. Click the Browse button on the bottom right, expand StrutsEJBTutorial and WEB-INF, and select classes. Click OK. 

Oracle ADF Data Binding Primer and ADF/Struts Overview
This article explains the basics of the new Oracle Application Development Framework's data binding layer (based on JSR-227), gives an overview of the ADF runtime and design time data binding facilities, explains how ADF integrates with and supports easily building Struts-based web applications, and puts the concepts into practice with three simple example applications.

In this article, we'll gain a high-level understanding of the Oracle ADF data binding concepts, see how we work with them at design time using Oracle JDeveloper 10g, and observe how they work in practice by studying a simple, working example of a Struts-based JSP application using Oracle ADF that complies with the best-practice Model, View, Controller design approach.

Implementing page navigation in portal applications using Struts portlets
Struts is a popular open source foundation designed to make complex Web applications easier to create and maintain. The Struts framework supports the Model-View-Controller (MVC) pattern and addresses many important application design and implementation considerations. To carry out page navigation in portal applications, WebSphere® Portal V5 provides tags that can be used by JavaServer Pages (JSPs) in developing both typical portlets and Struts portlets. This article focuses on the Struts framework's capability to create multiple modules, and how to implement page navigation methodology from JSPs in a sample Struts portlet application.

This article assumes you have a basic understanding of Struts applications, including how to build a Struts application in WebSphere Studio Application Developer, how to deploy Struts as a portlet, and an understanding of portal resources within WebSphere Portal. (See Resources for more information in these areas.)

Developing Struts with Easy Struts for Eclipse
This article shows you how to develop a Struts application in the Eclipse IDE, with the help of the Easy Struts plug-in. You'll get an introduction to Easy Struts, installation and configuration steps, and instructions on building a basic Struts application through a progressive example. Different ways of enhancing the Struts application -- such as connecting to a database, modularizing the application, internationalizing and localizing content, handling exceptions, and creating custom plug-ins -- are also covered. Finally, you will learn how to deploy your Struts application on the Tomcat Web server.

The Easy Struts plug-in manages all the complex configuration files, so you can focus on developing logic. Let's look at the 10 functions of Easy Struts that help you build a complete application:

1. Add Easy Struts support. Adds all the necessary Struts libraries to the project classpath, and creates the configuration files and the default resource properties file.
2. Easy Form. Creates a JSP file with the form properties, as well as a Form bean class with form properties getter and setter methods, and adds a form bean definition to the configuration file.
3. Easy Action. Creates an Action class and adds an action mapping definition to the configuration file.
4. Easy Action associated with a form. Creates a JSP file with the form properties, a Form bean class with form properties getter and setter methods, and an Action class. Also addes a form bean definition and an action mapping definition to the configuration file.
5. Easy Forward. Creates local forwards and global forwards, which define where the control will be forwarded to.
6. Easy Exception. Handles exceptions.
7. Easy Message resources. Creates resource properties files, which is especially important for internationalization and localization of content.
8. Easy Plug-in. Creates plug-ins.
9. Easy Datasource. Connects the application to a data source.
10. Easy Module. Modularizes the application.

Wiring Your Web Application with Open Source Java
This article will discuss how to combine several well-known frameworks to achieve loose coupling, how to structure your architecture, and how to enforce a consistent design across all application layers. The challenge is combining frameworks so that each layer is exposed to each other in a loosely coupled manner, regardless of the underlying technologies. This article will discuss one strategy for combining frameworks using three popular open source frameworks. For the presentation layer we will use Struts; for our business layer we will use Spring; and for our persistence layer we will use Hibernate. You should be able to substitute any one of these frameworks in your application and get the same effect. 

At one end of a typical web application is the presentation layer. Many Java developers understand what Struts provides. However, too often, coupled code such as business logic is placed into an org.apache.struts.Action. So, let's agree on what a framework like Struts should provide. Here is what Struts is responsible for:

1. Managing requests and responses for a user.
2. Providing a controller to delegate calls to business logic and other upstream processes.
3. Handling exceptions from other tiers that throw exceptions to a Struts Action.
4. Assembling a model that can be presented in a view.
5. Performing UI validation.

Migrating a Struts application to WebSphere Portal
Struts is a popular open-source development framework that provides a convenient way for modular applications to cleanly separate logic, presentation, and data. IBM WebSphere Portal has a built-in Struts Portlet Framework that enables Struts to extend its popularity to portal applications. This article shows how existing Struts applications can be migrated using the Struts Portlet Framework and then deployed in WebSphere Portal.

IBM WebSphere Studio Application Developer (hereafter called Application Developer) has built-in tooling and run time support for developing and unit testing Struts applications. With the WebSphere Portal Toolkit installed in Application Developer, portal applications can also be developed and unit tested with WebSphere Studio.

This article describes how to migrate an existing Struts application to a portal application with WebSphere Studio. This article assumes that you have basic knowledge of Struts and the Struts tools in WebSphere Studio. (For basic information on this topic, see Writing a Simple Struts Application using WebSphere Studio V5.)

Succeeding With Struts: Dynamically Sized Forms
In the previous installment of Succeeding with Struts, I alluded to the ability of DynaForms to dynamically size forms at run time. In other words, the ability to have a form that could be 5 rows long, or 10 rows, or 15 rows as needed. Perhaps a bit unwisely, I let the actual implementation of such a strategy as an exercise to the reader.

The first thing the execute method does, as any DynaForm-based action does, is to cast the generic ActionForm class to a DynaValidatorForm. This allows us to use the get and set methods on the form. Next, the method creates a three-element array of type Person. In this method the size is hardwired, in a real application this could be a size based on doing a select from a database. The important thing to consider is that the array is being created in the code here, not by the Struts engine itself. So any arbitrary number of rows could be created by the code in response to application requirements.


StrutsTestCase: Drilled-down Testing for Struts-based Java Apps
StrutsTestCase makes it easy to switch between mock testing and in-container testing. You choose mock testing or in-container testing by subclassing MockStrutsTestCase or CactusStrutsTestCase, respectively. You do not have to make any other changes to your code. Thus, if you want to switch from mock testing to in-container testing, simply do a textual search and replace to change all occurrences of "extends MockStrutsTestCase" to "extends CactusStrutsTestCase".

Security in Struts: User Delegation Made Possible
The Jakarta Struts framework has been widely adopted for creating web applications in the J2EE world. Struts makes it easy to create a web application because it builds on standard J2EE technologies like Java servlets, JavaBeans, JavaServer Pages, and custom tags. Validation of user input and internationalization of the views on the application are some of the important and better-known reasons to choose Struts as the basis for your web application.

In struts-config.xml you can specify a roles attribute, a comma-delimited list of security role names that are allowed access to the ActionMapping object in question. But that is all there is available regarding security in Struts, and it is surely not sufficient to implement the security delegation the application needs.

Advanced Forms Handling in Struts 1.1
This article is about the more advanced features Jakarta Struts offers in building HTML forms. If you know how to create forms in plain HTML then the step to building simple forms in Struts with, for example, a couple of input text fields, a checkbox or a radio button is not very complicated. When it comes to the more complex controls like the multi-valued selection list or a variable length list of input fields it gets more challenging. This is especially true when the possible selections are not fixed, but taken from some external source like a database instead. I've too often found myself struggling with the syntax and semantics of the HTML-tags when the forms get complex, and if you search the web for advice, you'll soon see that you have to collect information from many sources.

ActionForm or DynaActionForm - Making the choice
Imagine a Struts 1.0 world where an ActionForm was absolutely needed even for prototyping an HTML form in JSP using Struts custom tags. Things were good until the separation of concern came into picture. In real life projects, different people play different roles. Application developers have the responsibility of developing Java code and page authors would exclusively prototype the page and its navigation using JSP markup tags. Since the Java code beingdeveloped is constantly changing, the developer does local builds on his machine. Similarly the page author would certainly like to add or remove fields from the prototype during the page design. Since the HTML forms map to ActionForms, the above scenario implies one of two things.

1. The page author constantly pesters the Java application developer to modify the ActionForm.
2. The page author develops the ActionForm all by himself.

Developing and Deploying a Struts Application as a WebSphere Portal V5 Portlet
This article discusses the implementation of a portlet written for IBM  WebSphere Portal Version 5 (hereafter called WebSphere Portal) using the Struts Portlet Framework. Struts is an Apache Jakarta project providing a very popular open source framework for building Web applications. WebSphere Portal V5.0 provides the Struts Portlet Framework that supports the deployment of Struts applications as portlets. The Struts Portlet Framework also supports portal modes and devices within a Struts application.

The focus of this paper is not on developing a Struts Web application; instead, it is on the implementation and configuration required to deploy the Struts application as a portlet. You see how to create a portlet using the Jakarta Struts Framework, which is incorporated into the IBM Struts Portlet Framework. In WebSphere Portal V5 the Struts Portlet Framework ships Jakarta Struts 1.1.0.

Check Your Form with Validator
One major benefit of the Struts framework is its built-in interface for performing data validations on incoming form data. If any validations fail, the application redisplays the HTML form so that the invalid data can be corrected. Otherwise, processing continues. The Struts framework's simple validation interface alleviates much of the headache associated with handling data validation, allowing you to focus on validation code and not on the mechanics of capturing data and redisplaying incomplete or invalid data.

Struts' built-in validation interface, however, has its shortcomings. Often, for example, validation code is heavily duplicated throughout an application, because many fields require the same validation logic. Any change in the validation logic for similar fields requires code changes in several places as well as recompilation of the affected code. To solve this problem and to enhance Struts' validation interface, the Validator framework was created as a third-party add-on to Struts. Validator was later integrated into the core Struts code base and has since been detached from Struts and is now a standalone Jakarta Commons project. Although Validator is an independent framework again, it still comes packaged and seamlessly integrated with Struts. 

Providing a Flex Front End to Your Struts Applications
Struts is an open source framework that facilitates the development of web applications based on Java servlets and other related technologies. Because it provides a solution to many of the common problems developers face when building these applications, Struts has been widely adopted in a large variety of development efforts, from small projects to large-scale enterprise applications.

This article describes how you can provide your Struts applications with a rich front end using Flex technology. The objective of this article is not to make a case for Rich Internet Applications. It assumes that you already understand their value. This article focuses on the Flex/Struts integration from an architectural and technical point of view.

Professional Jakarta Struts: Advanced Action Classes
In this chapter, we dig further into the Controller components of the Struts framework by covering the built-in Action classes that come with Struts. Our goal is to provide you with a solid understanding of the Struts built-in actions and how they can be used to facilitate the design of your Struts applications.

The Struts Framework provides several built-in actions. A few of these are essential for any Struts application. Others are necessary to add cohesion to what would normally be a granular collection of related actions.

To use the ForwardAction, follow these steps:

1. Using the html:link tag with the action attribute, add a link to the JSP page that points to the action.
2. Create an action mapping in the Struts configuration file that uses the ForwardAction with the parameter attribute to specify the JSP path.

ASP.NET and Struts: Web Application Architectures
The last decade has reshaped the way that we do business and access information. Since the emergence of simple information portals in the early nineties, the Internet has rapidly evolved into a major and profitable forum for business and trade. This evolution has spawned two major standards for building enterprise Web applications—Microsoft® ASP.NET (and the Microsoft .NET Framework) and Apache's Struts (along with the J2EE framework).

Architects and developers from both the .NET and Java communities are now asking how these two technologies compare in scope, functionality and underlying architecture. In this paper we will provide an overview of the platforms, a rundown of the similarities and differences, and a review of the features that each framework provides to solve common developer problems. We will show how the industry standard patterns implemented in ASP.NET and Struts have helped reduce code complexity and accelerate development times. We will also explore the advantages and disadvantages of each offering, and the utility that they bring to the next generation of development.

Complete the MVC Puzzle with Struts
In this article, we’ll take a brief trip into the world of the Model-View-Controller (MVC) design pattern, and, in particular, we’ll look at how it is implemented using the Struts framework. We will start by describing the MVC pattern at a theoretical level, then move on to describe how we might ‘roll-our-own’ MVC framework. Once we’ve looked at this, we’ll describe Struts and show how this technology helps us quickly and simply build MVC-based Web applications.

Struts Provides Support for Dynamic Content
In this first installment, we'll look at how to handle dynamic contents to render a Web page under the Struts Framework, and then we'll move on to DynaActionForms and their advantage over normal ActionForms. In the final installment of this article we'll discuss Map-backed forms and how to handle dynamic contents using such forms. Liberal examples of code will illustrate these concepts. The contents discussed here are supported by Struts version 1.1 (beta) and later. The code was tested in a WebSphere Studio Application Developer (WSAD) Version 5.0 Enterprise Edition test environment.

The Struts framework defines actions what we'll call unit of work. Any user action (such as clicking a button on a screen) gets translated to some Struts action, which is defined at struts-config.xml (or the configuration file, which is how we'll refer to it from this point onward).

Handling Messages, Errors and Exceptions in Struts 1.1
This article is about Jakarta Struts 1.1, the most popular framework for building Java servlet applications. One of the new, useful features in 1.1 is the possibility to specify exception handling in the Struts config file. It's called "declarative exception handling", and it's one of the topics for this article.

You use exceptions when the application has encountered a serious error. The error could be an SQL statement that fails, or a connection to another computer that couldn't be established. As a programmer, you should first of all record the situation as precisely as you can. For example, writing information to a log file. You might also have to fix up a few things to keep the program state stable, but eventually you'll also have to inform the user of the situation. So to move forward, one issue in exception handling is how to handle messages, and I'll therefore start by explaining how you generally should handle messages for the end user in Struts. A special class of messages are "validation messages", which are sent out as the result of the validation of a form. If you're interested in how to set up forms validation you may want to read my article "Stepping through the Struts 1.1 Validator". 

Integrating Struts, Tiles, and JavaServer Faces
The Struts framework has been around for quite some time and has become the de facto standard that developers turn to when developing a J2EE Web application. The Tiles framework, which came soon after Struts, established its niche by offering developers the ability to assemble presentation pages using component parts. JSF, the newest kid on the Web-application-framework block, provides mechanisms for validating user input and handling user events; most importantly, it is a protocol-independent way of rendering user interface components. (For a quick look at these technologies, see the sidebar, "The major players.")

Although some of the functionalities in Struts and JSF overlap, they are complementary in other ways. The combination of these three technologies can provide an efficient way to develop a Web application, organize its presentation, and render custom user interface (UI) components independent of protocol.

Struts Applications and Multilanguage Support
This article introduces you to Struts and shows you how to build an application that can support multiple languages, preserve the MVC pattern, and help you to easily maintain your code. First, I discuss the principles of building multiple language support, including the different choices you have and showing you the enhanced possibilities that you can have with Struts.

There is an answer to this problem: Struts and its powerful application framework. With Struts, you can support multiple languages at a glance. The Struts framework separates your logic from the presented content, later referred to as messages. You can easily manage your code, develop in a safe way, and stick with the model view controller (MVC) pattern.

What's New In Struts 1.1
Jakarta Struts 1.1 is finally out the door. In reality, however, this release is more like Struts 1.99 or even Struts 2.0 when you get done looking at all the new features and functionality that have been added.

To begin with, the release is much more bulletproof than 1.0.2 was, mainly as a result of the thousands of developers who have been using the 1.1 betas and finding bugs. In addition, the same developers were finding the shortcomings of 1.0 as they deployed Struts as their application framework, and have been adding some sorely needed features.

Getting the Most Out of the Struts Tag Libraries
The Struts framework provides a set of six built-in Tag libraries that allow you to build the view part of the MVC without embedding Java code directly within your application JSPs.

The six Struts libraries are:

1. Bean Tags
2. HTML Tags
3. Logic Tags
4. Nested Tags
5. Template Tags
6. Tiles Tags

Struts 1.1 Controller UML diagrams
The goal of this article is to illustrate the Struts 1.1 Controller with UML diagrams. This article is an introduction to the Struts framework in order to help beginners programmers to understand the MVC model 2.

* Since Struts 1.1, the processing logic has been delegated to the RequestProcessor class :
1. Method processMapping selects the ActionConfig used to process the selection path for this request.
2. Method processActionForm retrieves the ActionForm associated with a mapping or creates and stashes one if necessary.
3. Method processPopulate populates the properties of the specified ActionForm from the request parameters included with this request.
4. Method processValidate calls the validate() method of the specified ActionForm, and forwards back to the input form if there are any errors.
5. Method processActionPerform asks the specified Action instance to handle the request, returns an ActionForward

Exploit XDoclet's Struts Capabilities
Struts and XDoclet fit well together. Let's start with a straightforward example. We have a Web form that asks for first name and last name, and when the form is submitted the name entered is stored in session scope so that it can be displayed throughout the site during the user's visit. In Struts, this process is implemented with the following pieces: form bean, a JavaBean with getters/setters for the firstName and lastName properties; JSP page, which uses Struts taglibs to build an HTML form; and action, an Action subclass that processes the form submitted.

Form Validation and Action Mapping
Action mappings in struts-config.xml can also be generated from Action subclasses tagged appropriately. You can see the tags necessary for generating a typical Struts action mapping. When adopting XDoclet, though, it is not necessary to use it for the entire struts-config.xml generation. In production, I prefer to hand code the action mappings, despite XDoclet's generation capabilities. Merging static content into XDoclet-generated artifacts is a provided feature, using merge points that are places in the templates that pull in an external file. The files reside in the mergedir (see Listing 1 in "Exploit XDoclet's Struts Capabilities"), and must adhere to naming conventions documented within XDoclet, and also within the generated artifacts (look for XML comments that indicate them). For hand-coded Struts action mappings, the <strutsconfigxml> subtask looks for a struts-actions.xml file in the mergedir. The mergedir attribute can be specified globally for the <webdoclet> task and can be overridden on a subtask basis if desired.

Server-Side Java with the Struts Framework on Mac OS X
Struts helps you organize your Java-based web applications by providing a framework based on a version of the Model-View-Controller design pattern. With Struts (or more formally, the Jakarta Project’s Struts Framework), you can combine Servlets, JSP, custom Struts tag libraries and other components using a unified framework that helps you design, create, and deploy stable web applications quickly. It requires a bit more work initially, to set everything up, but the value of the framework is realized later, when the ordered and componentized nature of your code lets you maintain, update, and reuse it easily.

Stepping through the Struts 1.1 Validator
To benefit from the article you need to have some experience with Struts, either version 1 or 1.1 RC. If you're new to Struts, I've written a couple of introductory articles, which quickly will bring you up to speed. They're listed in the resources section at the end of the article.

Before Struts 1.1 we had two choices of implementing forms validation: either in the ActionForm class or in the Action class. Both used the same technique to tell the Struts framework that validation errors were found: an ActionErrors object was returned holding a set of ActionError objects. Each of these described a specific validation error.

Architect Struts applications for Web services
In this article, you'll learn one route to this goal. You'll see how to architect an application based on the open-source Struts framework that can integrate with Web services. You should have some background in J2EE and Web services before you begin; I'll briefly introduce the Struts framework and the Model-View-Controller (MVC) pattern here, but if you haven't encountered them before, you should check out the Resources section below for more information.

Struts is an open-source framework for building Web applications based on the MVC pattern. Struts encourages application architectures based on the MVC pattern and provides services common to most Web applications.

In a Struts application, you can architect the Model layer so that the business and data retrieval logic are easy to reuse. This layer is responsible for running the application's business logic and getting the relevant data (for example, running an SQL command or reading a flat file).

Generate Web Output in Multiple Formats and Languages with StrutsCX
As an open source add-on for the Apache Jakarta Struts Framework (or Struts), StrutsCX has its roots in a pure XML- and XSLT-based, multi-language and multi-layout project. With StrutsCX you can easily generate different output formats like HTML, XML, or PDF using standardized XML and XSL technologies. Struts serves as the ideal server technology to perform these XSLT transformations.

StrutsCX also enables you to save and output content in different languages and encodings. Handling information in English, German, French, Spanish, and Italian—as well as in Chinese, Korean, Arabic, Russian, and any other language in the world—is simple with StrutsCX. 

Writing a Simple Struts Application using WebSphere Studio V5
This article describes how to create a simple Struts example using the built-in support in WebSphere Studio Application Developer 5.0.

Struts is an open source framework sponsored by the Apache Software Foundation. You can use it to maintain and expand Web applications. IBM ® WebSphere® Studio Application Developer Version 5.0 (hereafter called WebSphere Studio) has built-in Struts support for Struts 1.02 and 1.1 (beta 2). The Struts Configuration editor in WebSphere Studio allows easy modifications of the struts-config.xml file. This article describes how to create a Struts example using the built-in support in WebSphere Studio.

Put Struts' HTML Tag Library to Work 
This article explains the relationship among those classes and their roles in the application. Note that you must copy all the library files to the WEB-INF/lib directory yourself; they are excluded from the downloadable ZIP file to cut download time.

The Login application is a simple Struts application that will show how to use the HTML tag library, especially the form-related tags and the tag for error handling.

Learn Struts' Form-Related Tags
In this article series, I explained how to configure a Struts application to use the Struts HTML tag library. I also presented one of the two groups of tags in this library: tags that you can use independently. Here in Part 2, I'll continue with the second group of tags: the form-related tags.

The form-related tags consist of the <form> tag itself plus all tags that must be used inside it. For example, the <text> and <password> tags are form-related tags because it does not make sense if they are not placed inside a form.

Struts from Scratch
his article lays out the steps for installing Struts and a basic "Hello World!" sample application 'from scratch.' It assumes that you are brand new to Struts and that you're also fairly new to Java ServerPages (JSP) and programming in general.

The goal of this article is to go through the basics of installing and building a Struts application; the details of the application itself are not covered. The application is taken from my recent book, Struts Kick Start, and is covered in detail there. 

Struts Kick Start
"I started learning how to use the Struts framework, after I became fed-up with hacking web applications together with the digital equivalent of "Duct-tape Engineering". At that time there were no books available for the budding Struts developer, "Read The Fine Manual" was not an option ... you read the website, you read the code or you asked questions on the mailing list. This situation finally changed this fall with the release of a flurry of titles dedicated to Struts. I present here my thoughts on one of the latest: "Struts Kick Start".

Implementing Templates with Struts
The article covers some basic templating ideas in relation to portals, explains templating support in Struts, and rounds up with a discussion of Struts Template tags vs. Tiles, another templating mechanism.

Struts is a Web application framework that facilitates the development of Web sites using the MVC architecture. It provides a set of classes, tag libraries, and interfaces which can be used as the basis for Web development. Struts is an open source project and is developed under the Jakarta-Apache forum.

As with all Jakarta projects, Struts can either be downloaded in source code or binary format. In this article,we will use Struts 1.1b2. Though not an official release, this beta release contains significant improvements over version 1.0.2.

Jakarta Struts: Seven Lessons from the Trenches
The Jakarta Struts framework has only been around for a short time, but the impact it has made for Web developers is significant. The framework is based on widely accepted design patterns and is very extensible. Although the learning curve for Struts is manageable, there are still best practices when using the framework. These lessons become apparent during development of any medium- to large-size development project. However, a much faster way to get up to speed is to leverage lessons learned by others in the Struts community. Several of those lessons are offered here and are designed to increase your productivity and efficiency when building applications using Struts.

Your First Struts Application
I'll teach you how to install and configure Struts, and present the specification and deployment descriptor of a small application built within the framework. I'll discuss the application in more detail in the second part of this series.

First, though, you need to understand a few basics about Struts. It uses the Model 2 architecture, which is based on the MVC design pattern. Model 2 applications are ideal for serious developers because they create programs that are flexible, extensible, and easy to maintain. Model 2 is the recommended architecture even for simple applications, so it's crucial to have a framework on which you can build this kind of application quickly and easily. Apache's Jakarta Struts Project from Apache Software Foundation is such a framework, and this example will help you understand how to use it.

Struts and Tiles aid component-based development
This article does not discuss the MVC platform in depth. For that, see Malcolm Davis's developerWorks article entitled "Struts, an open-source MVC implementation." This article you're reading now discusses changes to Struts since Malcolm's article was published, including the Tiles library. For the code walkthrough, this article covers only the steps required for a minimal setup with Jakarta Tomcat 4.0 (Catalina). Please consult the manuals with your application server if you do not use Tomcat.

Struts and Tiles are aids for Web development, so you'll need to set up a Web container to experiment with them; the process for setting up Tomcat as your container and then the Struts and Tiles packages is described in the next section, in step-by-step fashion. These instructions also show you how to install this article's sample code. Once you've finished with that, you're ready to continue with the article. The Example 1 application doesn't take advantage of Struts and Tiles; it demonstrates the page-centric approach. By comparing it with Example 2, you'll see how much more structured and manageable Struts and Tiles can make your Web development. Finally, Example 3 demonstrates how straightforward it is to add functionality to a Struts and Tiles Web application that's already up and running.

Applying the MVC Design Pattern Using Struts
Struts, a Jakarta project, provides a framework for writing applications using the MVC architecture. Struts uses "ActionMapping," which enables the servlet to turn user requests into application actions. ActionMapping usually specifies a request path, the object type to act upon the request, and other properties as needed.

The Action object used as a part of the ActionMapping is responsible for either handling the request and sending the response back to the appropriate view (normally a Web browser), or passing the request along to the appropriate model. 

Boost Struts with XSLT and XML
In this article, we introduce Model 2X, a scheme that further enhances Struts. By replacing JSPs (JavaServer Pages) with XML and XSLT (Extensible Stylesheet Language Transformations), Model 2X offers an even better approach to separating logic and presentation. We start with an introduction to Model 1 and Model 2, describe how Struts implements MVC, and finally show how XML and XSLT can be used to improve the existing models.

While the Struts/JSP approach features many advantages over other models, it exhibits several drawbacks:

1. As in Model 1's case, nothing prevents a developer from embedding application logic into the JSP. Experience shows that many developers actually fall into that trap, often to perform a quick fix. This can lead to applications that are hard to understand and maintain.

2. The JSP syntax is not XML compliant and therefore fails to guarantee that resulting XML or HTML documents will be well formed.

3. The developer must learn new APIs -- the Struts tag libraries. Experience shows that gaining an understanding of the Struts tag libraries, particularly the bean and HTML libraries, can take a long time.

4. You can't implement a real processing pipeline in the view with JSP. Only basic includes and forwards are possible, effectively limiting the view's flexibility. For example, separating layout and style proves difficult.

5. With JSPs, you must recompile after every change, which can be time consuming. Just ask any JSP developer waiting for page compilation after every mouse click. 

Learning Jakarta Struts, Part 3
This is the final article in a three-part series on the Struts framework.

In the first article, Introduction to Jakarta Struts Framework, I defined the Struts framework, discussed what it can accomplish, and provided an overview of the various components used throughout the framework. In the second article, Learning Jakarta Struts, I described building a simple sample application from scratch using Struts 1.0. This article will show you how to use the Struts tags to access the ApplicationResource file from a JSP.

Learning Jakarta Struts, Part 2
This is the second article in a three-part series on the Struts framework. In the first article, Introduction to Jakarta Struts Framework I defined the Struts framework, discussed what it can accomplish, and provided an overview of the various components used throughout the framework. In this article I describe building a simple sample application from scratch using Struts 1.0. The third article will show you how to use the Struts tags to access the ApplicationResource file from a JSP.

Taking a step-by-step approach should open some new doors and show the potential of using Struts in your application development. If you aren't familiar with Struts terminology, take a quick read through the introductory article.

Introduction to Jakarta Struts Framework
This article focuses on one aspect of that development process: how to use the Struts framework to assist in front end integration. Struts is an open source framework developed for encouraging an application architecture based on the Model-View-Controller (MVC) design paradigm, useful in building Web applications with Java servlet and Java Server Pages (JSP) technology.

This article assumes a working knowledge of JSP, servlets, custom tag libraries, and XML. Refer to some of my previous columns on JSP customer tag library development if you need to brush up on the basics. This column is Part One in a two-part series on using the Struts framework.

Struts, an open-source MVC implementation
This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control change in your Web project and promote specialization. Even if you never implement a system with Struts, you may get some ideas for your future servlets and JSP page implementation.

If you have worked on a large-scale Web application, you understand the term change. Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data. Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifications, as part of the implementation. You may never implement a system with Struts, but looking at Struts may give you some ideas on your future Servlets and JSP implementations.

Integrating and Mapping a Web Application MVC Pattern
Struts is an implementation of the presentation tier using MVC. The Struts controller encapsulates the presentation logic, handling the interaction of the JSP pages view with the JavaBeans model, which might access a database through JDBC.

Struts delivers on its promise of a framework that follows the MVC design pattern by effectively segregating the various components into a small set of extendable classes. Also note the declarative nature of its XML-based action mappings and JSP tags.

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

6 comments so far (post your own) View All Comments Latest 10 Comments:


This is Very good tutorial for Developers

Posted by sreedevi on Wednesday, 11.7.07 @ 15:29pm | #36282

I want concept that how can chat server application develop using struts.. anybody having idea about this mail me above mail address

Posted by barani on Wednesday, 09.19.07 @ 12:13pm | #27833

Hello R.S.Ramasamy sir
Sir I m Arun Prasath.J from A.C.CET.
now i m working in ACCORD Softwares&Sytems.

I have one book JAVA STURTS from DREAMTECH Publications. Its Cost about 100 rupees in a old book shop. if u need this book then send me a msg to me. or call to my number 099162 50056.
my mail Id's
beat_arun@yahoo.co.in , prasathj@gmail.com.


Thanking u sir...

Posted by ArunPrasath on Monday, 08.20.07 @ 17:39pm | #23785

Hello R.S.Ramasamy sir
Si