Struts Survival Guide
Even before I started reading the book, the fact that stood out most was its pricing. The book costs $14.95, and is great buy for everybody and especially students. The book is light -- just 224 pages -- and is an easy read. The authors' style is neither dry nor humorous, but very convincing and developer friendly. Bottom line: It does not put you to sleep.
There are two aspects to any framework: the first aspect is the features of the framework itself; the second aspect is how easy it is to use them effectively. This book does justice to both aspects of Struts. It covers enough framework features to justify its title, starting from bare bones and then slowly guiding you to more advanced topics. In addition, there are chapters dedicated to dealing with variety of scenarios in web applications where Struts can be used to solve the problems effectively. This is the area where the book shines.
Chapter-wise reviews The book starts off with an excellent introduction to MVC and how Struts fits into MVC. It then explains the basics of Struts very well and develops a hands-on application in Struts in the first three chapters.
The fun starts from Chapter 4 onwards. Chapter 4 covers advanced Struts concepts and presents some interesting ideas about Struts Action design. Of particular interest are the coverage of how to protect your JSPs from direct access, using SwitchAction to navigate between multiple Struts modules. The different mechanisms of Action chaining and scenarios where Action chaining is not recommended is also an enlightening read. One of the controversial points in the book is that author discourages you from using XDoclet and explains why XDoclet is not a great idea with Struts.
Chapter 5 covers the validation in Struts. It is the shortest write up on Validation I have ever read and yet it beautifully explains the Commons Validator and its integration with Struts. In the context of validation, the author also explains when to use DynaActionForm and its derivatives and when not to.
Chapter 6 deals with Struts Tags. Reading this chapter was such a refresher. Other books on Struts have bored me with details of each attribute of each tag in Struts. I find this approach non-intuitive since that information is supposed to be a cross-reference and available on Struts web site anyway. Not so with this book. This book takes the approach of explaining the basic tags by example. In chapter 6, the author dives straight into practical aspects of building web applications with Struts. One of the very first illustration is why and how to modify BaseTag (the one that renders ) to suit the real life deployment scenarios. Next the chapter takes up one of the serious issues with check boxes regarding their state and provides a solution. The chapter provides technique for seamlessly integrating JavaScript validations with Struts validation. A lot of Struts web application that we develop do not use plain buttons. Instead image buttons are used. Perhaps the author was very aware of this fact and the lack of support for image based form submissions in Struts. That is why the chapter and the book has frequent references and solutions for dealing with Image buttons. It all starts in this chapter with a great introduction and some classes that make the form submission on the JSP transparent to the Action classes.
The Chapter 6 provides little details on the Struts Bean tag library except for dealing with multiple resource bundles and some design tips. Perhaps the reason is that the bean tags are so straight forward and covered well in the Struts web site. Another highlight of the chapter is a short yet great coverage of JSTL as a background for Struts-EL. The JSTL is introduced in the context of Struts Logic tags as a solution to deal with convoluted and and confusing nested tags. The section on Struts-EL is really short and could have been more.
The creme la creme of Chapter 6 is the section on dealing with List Forms. Sometimes you often have to deal with Forms with collection, edit the collection or delete the collection. Developers are confused on this topic as is evident from the postings in Struts mailing lists. The author does a great job of resolving the mystery surrounding editable collections in Forms. The author also does a great job of integrating the Pager Taglib from JSPTags.com with Struts and how a high performance page traversal mechanism can be set up based on the ValueListIterator pattern (Core J2EE Pattern) and database specific mechanisms.
Chapter 7 is a very decent way to learn Tiles. Tiles can be very confusing due to its capability to achieve the same thing in numerous ways. The author sticks to just one approach of using Tiles with Struts and defends why that is the best approach. The pros of this approach are there are confusions and the learning curve with Tiles is flattened. Coverage of Tiles Controller is missing and is desirable.
Chapter 9 on Exception handling in Struts deserves some mention. It is one of the best exception handling chapters I have ever read. Most other books on Struts limit their exception chapter to explaining differences between Checked v/s Unchecked exceptions and telling how the tags work in the struts-config.xml. The coverage of Exception handling in this book alone is worth the price of the book. It provides a solid framework to handle Exceptions in Struts, log them in a centralized manner and report and alert in a production environment.
Chapter 10 is for folks who want to customize Struts and reap its benefits in design and development of production systems. It presents four examples of how Struts can be effectively customized. The best among them was how to how to handle duplicate form submissions in a generic manner. We all have to deal with duplicate form submissions in daily life and handle them on use case basis by using the Synchronizer tokens. The technique illustrated here no doubt relies on the Sync token but uses it a very ingenious manner, presents a generic Action class. I liked this technique. Other techniques I liked are that the chapter provides a Dispatch Action like functionality for Image based form submission. The DispatchAction in Struts is great, unfortunately I can use it only under certain restrictions. One of them is that the all of the buttons have to have the same name. This technique removes that restriction and opens a world of possibilities for designing cleaner applications while providing enhanced user experience.
If there is a feature in Struts which is not the best way to attack a problem, this book tells you that. The chapters are also interspersed with design tips for designing your Struts application better. In summary, this is a pragmatic Struts book and a highly recommended read for developers and architects already familiar with Struts. You will certainly pick up quite a bit of Struts tricks that will help you design better Struts applications. If you architect, design and develop Struts based applications for your living, do yourself a favor - Go buy this book. Even if you don't know Struts, you can learn it fast with this book. The only requirement is that you should already know the basics of how to develop J2EE web applications.
You can purchase Struts Survival Guide: Basics to Best Practices from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Struts is fully 100% buzzword-compliant.
The rule of today's software development industry is that everything but Java sucks unless you're writing device-drivers. Once you learn how to at least pay that rule lip service in your job interviews you'll have a career's worth of work.
Complicated problems require complicated solutions. Simple problems require php, asp, or coldfusion. Most problems are simple. Use the right tool for the job, but don't complain if the right tool is hard to use. It's hard to use because it does something.
[This sig left intentionally blank.]
Java code and markup together is messy and difficult to maintain
That's why you create/use taglibs! You should never ever ever have java code exposed in a modern JSP page.
J2EE and Struts are both frameworks, but for entirely different things. What you have suggested bears no relation to Struts or J2EE. What you describe also isn't really a cluster (what happens when a node fails half way through running a transaction? no support for shared state? sessions? stickyness?) and most people don't cluster with a "framework" anyway, they either use simple load balancing hardware, or if they need more features they pick an appserver appropriatly (for example they might use WLS instead of Tomcat/JBoss).
If you really think it's easier to write your own Struts than use the one that's already written...well...either you are writing extremely simple apps or you are some kind of super-coder. There is a reason people don't all write their own version of Linux...
---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"
Why is mixing Java-code and markup a downside?
... you can just add an offset in the loop and pass it in the url or something like that.... It's done in 15 minutes...try that with your struts and tapestry stuff......
When using struts you have some kind of XML-document in which you cannot see the difference between controll-statements (logic) and markup because it's all in the same format.
That's unreadable and unmaintainable.
The problem with stuff like struts, velocity, cocoon, tapestry etc. is that you have to change stuff in multiple files to change simple behavior.
For instance;
If you have a page with a table of 34983 rows, and you want to split them ("go to next 100 results") in chunks and you created your page with all those fancy framework you have to change stuff in different-files, you have to create a new 'tag' and perhaps you have to "deploy" or what-ever....It's just not maintainable.
In a simple JSP with a for-loop (just java-code) and an iteration which prints a
:wq!
Poor Man's WebObjects.
MVC for J2EE via WOF is what you want, but if you want Linux than one can see the popularity of Struts and other MVC frameworks on none Apple supported platforms.
Apache Cocoon2 Frameworks are much more interesting than Struts, personally.
Thank you. :)
But what kind of real-world Struts stuff have you done, instead of just FOSS messageboards that you put together in your spare time? When you're dealing with real-world constraints like time, money, and requirements from non-technical users, Struts works against you at every turn.
Never used struts at work. But it sounds like what you're really saying is that struts forces you to design a little, rather than just pumping out X lines of code/hour to meet a deadline. A lot of people get forced into pumping out code at work, and I don't think it leads to anything good, regardless of the tools you use. I'm lucky enough to have a boss that stands behind me when I think I need to spend a bit more time doing something the right way. Given that, I'd feel confident about using struts in commercially.