Award-winning Top 25 JUG!

Book Reviews

This book review was submitted by a DenverJUG member as part of the Book Review Program.

BOOK DETAILS

Programming Jakarta Struts, 2nd Edition
Authors: Chuck Cavaness
Publisher: O'Reilly
Publish Date: June, 2004
Pages: 470
ISBN: 0-596-00651-9
Publisher's Book Description

Review Date: October, 2004
 

REVIEWER

Krishnan Kannan

REVIEW

Summary
This book is for someone who has already started learning Apache Struts and wants to understand more about the core concepts of the Controller servlet and the classes like ActionForm, RequestProcessor and Action classes. If you want to build a Struts application from scratch, this book doesn't give you any examples or steps explaining how to do that. I view this book more of a reference guide for Struts components than showing me how to build a Struts application. The author discusses some of the best practices that can be employed while building your application, which I think is very valuable. This book mainly covers Struts version 1.1 and the author carefully highlights what are the new features in this version and how it was dealt in the older version of Struts.

Chapter 1
This chapter provides a good but brief overview of the web technologies such as CGI, Servlets, JSP, the Model-1 and Model-2 architecture. This will be helpful for a reader who is new to the Java-based web component development. The author provides a list and a brief description of other frameworks that are similar to the Struts framework at the end of this chapter, which will give the readers an idea about what competing/supporting frameworks are available. This chapter mentions EJBs (session beans, entity beans) and their integration with JSP technology.

Chapter 2
This chapter will be helpful for someone new to the J2EE web-tier components like JSP, Servlets, HTTP, HTTPS and such concepts. Even though it doesn't talk much about Struts, this chapter describes the fundamental technologies that are used in the Struts framework, like the "scope" concept and the "forward vs. redirect" processing differences.

Chapter 3
This chapter gently introduces the overall picture of what Struts consists of -- model, view and controller components. It contains a simple Struts application where each of the component's classes are shown and explained very well. I find this as an effective approach to introduce the concepts to someone new to the Struts framework and to show how the various classes are involved in different components.

Chapter 4
This chapter does a very good job of explaining the important Struts configuration files -- web.xml and struts-config.xml. Struts 1.1 has drastically changed the configuration file struts-config.xml, and this chapter explains the differences and explains in what sections are allowed and what each sections contains (attributes, required values, etc). I found this explanation very helpful in understanding the important components of the configuration file. There are many references to the (pg. 74, 81 and 98) Multiple Application Module feature that is now supported in Struts 1.1. I found the first two references pretty useless as they repeat the same information. Only on page 98 the author shows how the multiple application modules are referred in the web.xml file. The Struts Console tool mentioned in this chapter is a very good tool for anyone who is going to start developing with Struts. I downloaded it and added it as a plug-in to Eclipse pretty easily. This tool is very easy to use but provides a very great benefit of not mucking around with the XML file as it clearly shows each section in the GUI format and it's easy to add/edit or delete values from it.

Chapter 5
This chapter talks about one of the main components of the MVC architecture, namely the Controller component. It describes in detail how the Struts initialization process works and the core classes ActionServlet, RequestProcessor and Action. Each of the methods in the RequestProcessor is explained briefly and their behavior is highlighted. The Struts pre-built Action classes are explained in another section, and it shows how the user can utilize them easily. This is a pretty good chapter to read to understand about one of the core concepts of Struts.

Chapter 6
This chapter discusses the Model component of the MVC architecture. Nothing in this chapter is specific to Struts. Most of these concepts apply to any other n-tier architecture application. It defines and talks about the Business Object and how it should be used in an application. Some of the best practices and related J2EE patterns (DAO and Business Delegate) are explained in here. The impedance mismatch between the OO modeling and the RDBMS data model is discussed briefly, and the author shows some of the OR-mapping frameworks like Hibernate. This is another good chapter, even though doesn't have much to say about Struts.

Chapter 7
Another main component of the web application and the final piece of the MVC architecture -- View component -- is described in detail in this chapter. The main class ActionForm in the View component is explained very clearly and thoroughly here. How to associate an ActionForm to Action is highlighted. The ActionErrors and ActionMessage classes are also explained here. Another important concept, the DynaActionForm, is explained here and shows how it can be configured in a Struts application.

Chapter 8
This chapter is a great introduction to JSP custom tags and how to use them in a Struts application. Some core tags, like the Base tag, HTML tag, form tag, error tags, etc., are explained in a reference format showing their attributes and description. The JSTL library is mentioned briefly and the author explains how it fits into the Struts framework.

Chapter 9
If you want to extend the Struts framework, this chapter is for you. It shows the Struts plug-in mechanism and the several extension points available that can be utilized to extend the framework. Extending the controller components like ActionServlet class, RequestProcessor class and Base Action class are shown with examples in this chapter. Some of the view components also have extension points that are explained in here briefly.

Chapter 10
This is a pretty interesting chapter that shows how exceptions can be handled in a Struts application. I found the declarative exception handling very interesting because it removes some of the laborious exception-handling code that we need to add in the Java code. It's a pretty neat concept, and is shown with good examples. This declarative exception handling is supported only from Struts version 1.1, so it's important to understand this concept and its usage.

Chapter 11
Validation in a Web or user interface application is an important feature. This chapter talks about the concept of validation, and shows how it is supported in the Struts framework. The Validator framework allows you to move all the validation logic completely outside of the ActionForm, and declaratively configure it for an application through external XML files. This chapter dwells into the details of how the validator can be used with the ActionForm and you can create custom validation rules. This is a pretty good chapter to read and get a hang of the concepts of declarative validation in Struts.

Chapter 12
If you are into internationalizing your application, this chapter shows how you can do that in a Struts application. The Java ResourceBundle and Locale classes are described briefly. It also discusses the Struts Resource Bundle support and how it can be used with some examples.

Chapter 13
If your Struts application interfaces with Enterprise Java Beans (EJBs), this chapter shows some of the best practices of implementing such interactions. The concept of Business Delegate is touched again in the context of EJBs. The author has chosen to highlight the example of EJBHomeFactory instead of the J2EE Service Locator pattern for managing the EJB Home and Remote references. This chapter also discusses Dynamic Proxies, which I think is kind of advanced. The example shown is a bit complex and doesn't clearly highlight the advantage of this pattern.

Chapter 14
This chapter covers another important UI design feature called Tiles. Tiles is used widely in JSP applications to design the layout of the web applications, and have wonderful support for reusable JSP and layout components. I recommend anyone who hasn't used Tiles to read this chapter to understand the great features that it offers and how it simplifies JSP development. Some of the core tags in the Tiles library are shown here with details about their attributes.

Chapter 15
Even though the title implies this chapter will be covering only logging, it provides more information than that, such as Filters and Event Listeners. It gives the reader a good idea of what these features are with some basic examples of using them with a servlet. For the logging part, the Apache Commons Logging API is covered with a description on how to install and use it. The log4j implementation of logging is described pretty well in this chapter, and shows how to integrate it with a Struts application.

Chapter 16
This chapter shows how a Web application can be packaged and deployed to web-application servers, like JBoss and WebLogic. It shows the appropriate tools to do the packaging in the correct way and automate most of the packaging tasks. The ubiquitous Java tool, Ant, is described here, and shows how it can be used for creating the WAR file for deployment. Pretty good chapter to read if you need ideas about packaging and deployment.

Chapter 17
Once you are done with developing your Struts application, you may be faced with the task of tuning its performance. This chapter shows the tools available to measure the performance of your application and shows how to improve the performance.

Chapter 18
This chapter talks about an emerging web user-interface technology called Java Server Faces (JSF). It briefly discusses what JSF is and how it collaborates with Struts. If you want to explore JSF, you are better off reading the information from JSFCentral and Sun's JSF web site.

Sample chapter: Chapter 11: The Validator Framework

Book excerpt: Chapter 14: Using Tiles