Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming Books Media The Internet Book Reviews IT Technology

Struts Survival Guide 113

Wilson Fereira writes "The Jakarta Struts framework is undoubtedly the most popular MVC framework for developing web applications in J2EE. A lot of books have emerged to satisfy the appetite of avid Struts reader including the two famous books from O'Reilly and Manning Publications. Struts Survival Guide: Basics to Best Practices (SSG) is a new addition to the already growing list of Struts books. SSG is from a new comer in the publishing business - ObjectSource Publications." Read on for the rest of Fereira's review.
Struts Survival Guide: Basics to Best Practices
author Srikanth Shenoy, Nithin Mallya
pages 224
publisher ObjectSource Publications
rating 8
reviewer Wilson Fereira
ISBN 0974848808
summary A short but valuable guide to the Jakarta Struts framework.

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.

This discussion has been archived. No new comments can be posted.

Struts Survival Guide

Comments Filter:
  • by primus_sucks ( 565583 ) on Wednesday April 28, 2004 @02:05PM (#8998601)
    Here's a better [manning.com] struts survival guide:) (Sorry for the flamebait, I've been having another frustrating day developing a struts application...)
    • See also: "Spring" (Score:3, Interesting)

      by persaud ( 304710 )
      link [theserverside.com]

      "... like many developers, we have never been happy with Struts, and feel that there's room for improvement in MVC web frameworks. In some areas, such as its lightweight IoC container and AOP framework, Spring does have direct competition, but these are areas in which no solution has become popular. (Spring was a pioneer in these areas.)

      ... Spring provides a consistent way of managing business objects and encourages good practices such as programming to interfaces, rather than classes. The archite

  • by Muda69 ( 718162 ) on Wednesday April 28, 2004 @02:09PM (#8998661)
    Then I found this book. I devoured this book in its entirety in a week. Now, I not only know the basics of Struts, but also understand best practices and Strategies in Struts. Lucid presentation, Easy read and great stuff. A very practical book. I already find myself using the code from this book in my current project. And my co-workers think I am a smart Struts geek !
  • by webusr2 ( 774977 ) on Wednesday April 28, 2004 @02:13PM (#8998721) Journal
    Struts vs. Strut

    One thing that I'd be sure to look for in a Struts book is a section on how to correctly use the word Struts in a sentence of English language.

    The issue here is that in some respects, 'Struts' is a singular noun referring to a framework - yet it ends with an 's' tricking many English-As-A-Second-Language-IT-Professionals into thinking that they need to apply rules of plural nouns. In extreme cases, I've heard people take the liberty of removing the 's' completely! as in:

    "We will update the Action class of the Strut."

  • Maypole (Score:4, Interesting)

    by bnavarro ( 172692 ) on Wednesday April 28, 2004 @02:42PM (#8999091)
    Anyone know how Struts compares to Maypole [simon-cozens.org], a Perl-based MVC? I just started reading up on MVCs, and Maypole claims decent functionality can be achieved with as little as 10-20 lines of coding.

    Also, while I'm thinking of it, does anyone know of a decent Python-based MVC?
    • Re:Maypole (Score:3, Insightful)

      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.
    • After I read "How to use Model-View-Controller [uiuc.edu]" which explains very well how the MVC paradigm can be useful, I am not sure that web applications can actually benefit from using MVC. Since it is based on the user making a request, there is no need for the view to be linked to to a model and to update itself. The application can just get or check the data with each request.

      Most of the Struts benefits come from the taglib that maps object to html tag.
    • Also check out Mojavi [mojavi.org] a PHP MVC Framework. It is arguably the best MVC framework for PHP. The for PHP part is the qualifier because all the other PHP MVC frameworks I've seen are a direct port of Struts and do things bad for php (like load XML definition files on every request -- that's bad, mm'kay?).
  • by painehope ( 580569 ) on Wednesday April 28, 2004 @02:48PM (#8999180)
    who out of the corner of their eye, read :
    Sluts Survival Guide
  • It usually takes less time to develop you own framework than to learn Struts, J2EE, etc...

    Here a quick tip for a simple cluster. Use JMS or another queued message pool. Start as many servers as you need, and let each message be handled by whichever server is available. I was doing this in java in '97 and I still haven't seen a framework that beats it in performance, ease of use, or versatility.
    • Re:DIY (Score:4, Insightful)

      by radish ( 98371 ) on Wednesday April 28, 2004 @03:37PM (#8999849) Homepage
      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...
  • Too complicated? (Score:4, Insightful)

    by cyberwitz ( 767170 ) on Wednesday April 28, 2004 @03:02PM (#8999380)
    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.
    • by Anonymous Coward
      I know PHP, ASP, Perl, C, and C++ quite well. I've written commercial applications in all of them. I've seen some coldfusion applications.

      I've come to the conclusion that there really is no need to use a language other than Python or Java unless you have to.

      I can't understand my own Perl code after 3 months of not touching it.

      C/C++ code breaks every time a library changes from a service pack on windows or an update on Linux. You can't leave C/C++ code untouched and expect it to run 6 months later.

      ASP
      • Java maybe a clean language, but if you work for a company that wants an application in any reasonable period of time, Java might not be your answer. I've seen so many contractors milk Java and when they show you the code, its bloated and convoluted. There is a right language for the right job -- if you have a handful of users, why use Java? Coldfusion runs on just about any platform and examples like Benorama.com [benorama.com] show that if you want to have MVC with traditional model 1 languages its possible. For a littl
        • If Java is too complicated you are using it wrong. Coldfusion is bad practice as it encourages large web pages with embedded code. Good practice is to use MVC with systems that are designed for it, such as struts, JSF, Turbine etc.

          If you are a fan of coldfusion, you can do the same thing in Java: the JSP standard tag libraries have all the same functionality and the EL (expression language) version allows run-time interpreted code to be embedded. The advantage of JSP is that, unlike cold fusion, it rea
      • Python is not that slow. Using psyco, you can get almost C-like speeds. I've seen benchmarks that showed this (right here on Slashdot). And for Zope there is a SpeedPack that integrates it with psyco...
    • There are no simple problems, only problems that seem simple when you start them. Use tools that allow you to deal with these problems when they become complicated and you will save time and effort.
  • Check out spring... (Score:5, Informative)

    by D-Cypell ( 446534 ) on Wednesday April 28, 2004 @03:47PM (#8999980)
    I used struts for a short while on a previous project, it seems to have gotten a little bloated recently though.

    A framework I am working with currently is spring [springframework.org].

    Spring is a superb framework for Java development and includes a pretty impressive MVC web toolkit as well as many other tools and features. The AOP stuff is very nice and the whole inversion of control/dependancy injection implementation simplifies code drastically.

    Ive used quite a few different frameworks, but so far... this one is my favourite.
    • by pbur ( 88030 ) on Wednesday April 28, 2004 @04:48PM (#9000758)
      I must second this. I was able to use Spring's MVC and other tools very quickly as it was easy to understand and the examples were very good. At the time I started, the docs weren't very good, but they've gotten a lot better.

      I've tried using Struts a few times, but it kept failing my 30 minute rule. (30 minutes to at least get some demo going other than "Hello World") Whereas I had the same idea of a demo going in Spring in about 15 minutes, on the first try.

      I think Spring's advantage is it's IoC style of configuration and it's use of POJOs instead of the Struts style of extending one of their classes for everything.
  • by Anonymous Coward
    If you are starting on a new java web app i'd recommend picking up one of the next-generation mvc frameworks be it Webwork2, Tapestry, Spring-MVC, Maverick or JPublish, these are all much better than Struts
  • STRUTS is the ... (Score:4, Insightful)

    by tyrione ( 134248 ) on Wednesday April 28, 2004 @04:01PM (#9000142) Homepage

    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.

    • Struts & WebObjects? (Score:4, Informative)

      by TapestryDude ( 631153 ) on Wednesday April 28, 2004 @06:33PM (#9001973) Homepage
      I think you tarnish the name of everything the geniuses at Apple pioneered with WebObjects by even comparing it to Struts.

      Fundamentally, Struts is a refactoring of the basic servlet API, but is still intrinsically operation-based (as are pure servlets).

      WebObjects, and it's thematic successor Tapestry [apache.org] are component based approaches, an entirely different mindset. I created Tapestry and I have about two years of Struts experience ... Struts is a straight-jacket. Component frameworks offer incredible advantages in terms of clarity and developer productivity. Struts offers very, very little except a slew of books that have the daunting task of explaining in detail something that should be (was intended to be) very simple.

  • by Anonymous Coward
    I know that most of you won't agree with me, but after developing applications in both environments it is clear that asp.net is better than struts in many ways. Of course, it should be seeing as how MS pretty much ripped it off and added to it. The people who make the struts framework have some catch up to do to be on par with what is coming from MS in their next version.

  • Struts rocks! (Score:1, Informative)

    by Anonymous Coward
    We have four mid-size/large apps developed with Struts and this framework saved us a lot of grief. There are plenty of books devoted to Struts, not sure if this one is the best (I personally like one by Chuck Cavaness) but it's good to see that Struts gets the attention it deserves.
  • .. once I discovered echo and [nextapp.com] echopoint [sourceforge.net]

    I haven't looked back since.

    To sum echo up:

    Write web applications using a swing like API.
  • Anyone read both this one and Struts in Action?

    If so how do the two compare - is either one better than the other?
  • by Decaff ( 42676 ) on Wednesday April 28, 2004 @07:03PM (#9002281)
    The inventor of Struts has moved on and has been working with Sun to produce a new and more versatile framework called Java Server Faces:
    http://java.sun.com/j2ee/javaserverfaces/
    This is the framework that is being adopted by all major java IDE designers: NetBeans, Borland, Oracle etc. Fortunately, its not difficult to integrate struts and JSF, but for newer projects, JSF makes sense. It has an advantage in that the GUI doesn't have to be web pages - you will be able to 'plug in' WAP, Swing etc.
    • by activewire ( 515493 ) on Wednesday April 28, 2004 @08:51PM (#9003135)
      Not exactly. JSF does not "replace" Struts at all, rather, JSF is more of a replacement for JSP's. What may have confused you is that a major feature of of Struts is tag libraries for JSPs, those taglibs WILL be abandoned in a future Struts release once JSF has matured. Read it all here http://jakarta.apache.org/struts/proposals/struts- faces.html [apache.org] Basically, the MVC aspect of Struts will live on, only the "V" part (view) will become JSF instead of JSP.
      • Not exactly. JSF does not "replace" Struts at all, rather, JSF is more of a replacement for JSP's.

        This is completely wrong. JSF is a total replacement for struts at all levels: model, view and controller. The JSP aspect of JSF is only one implementation of the presentation layer of JSF, and the reference implementation of JSF includes a JSP taglib front-end. One of the big advances of JSF is that it can in principle render all sorts of interfaces: WAP, XML, Swing, SWT, yet the underlying Java code and
      • I don't usually try and post the same thing a second time to try and get modded up, but the 'Informative' parent post is simply factually incorrect. I am not confused at all. The situation is very clear: JSF is a full replacement for struts at all levels, Model, View and Controller. You are confusing the presentation tags of JSF with JSF as a whole.

        A direct quote from the author of struts:

        "JSF provides functionality that overlaps that
        of Struts (my misconception was that JSF was strictly a UI component
  • XWork / WebWork? (Score:3, Interesting)

    by danharan ( 714822 ) on Wednesday April 28, 2004 @07:05PM (#9002298) Journal
    I have been using Struts for over a year now, and although I'm over the steep learning curve, I can't help but think there's something simpler.

    Some have mentionned Spring, and I'd love it if anyone here could tell me how that compares to Struts, especially if they tried OpenSymphony's XWork or Webwork.

    Any recommendations?

"Protozoa are small, and bacteria are small, but viruses are smaller than the both put together."

Working...