Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Struts Kick Start

Posted by timothy on Tue Dec 31, 2002 11:35 AM
from the your-stuff dept.
Simon P. Chappell writes "I started learning how to use the Struts framework in late in 2001, 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". The rest of Simon's review follows.
Struts Kick Start
author James Turner and Kevin Bedell
pages 481 (29 page index)
publisher Sams
rating 9
reviewer Simon P. Chappell
ISBN 0672324725
summary You need this book

What is Struts?

Struts is a framework for developing web applications. It is a distilation of the current set of known best practices into a working code set that can be extended to meet almost any web application requirements. It part of the Jakarta Project at the Apache Software Foundation.

What do I know about Struts?

I have been developing web applications, using Java, for four years and using struts for over a year, and am a regular participant on the Struts mailing list. I was also a technical reviewer for one of the other Struts Books released this fall and was recently invited to speak at the University of Wisconsin, Eau Claire on the use of Struts.

What's good about this book?

There are many excellent things that I could point to. I particularly like the obvious depth of research that accompanies this book. There is a very interesting history of the development of the MVC design pattern and they even name the inventor. Do you know who invented MVC? If you want to know, buy the book! The chapters cover everything that you will need to know, in the order you are most likely to need to know it. There's even a chapter explaining the "struts-config.xml" file's DTD! (You may want to skip that on the first few readings :-)

There is good coverage of the Struts taglibs. I see a lot of questions about these on the mailing lists, so this information is very timely and it looks very well explained.

I like the coverage of other open source tools that work well with Struts. This is an important point because Struts does not do everything for you (by design), so there will be areas that will benefit from other tools. I'm looking forward to trying out some of their recommendations and easing my own Struts development lifecycles.

What's not so good?

Just one niggle, and it's more of a programming style issue, but in their example code they have references to their business objects. They explain that it is important to separate out business logic from action logic, which it is, but then proceed to use their business object within the action.

Now, I realise that example code is not the same thing as robust, production-ready code, but when people are first learning a language or framework, they tend to copy exactly what they see in the book they are learning from. Even though example code should be light on error checking, it should be heavy on correctness and good style.

Should you rush out and buy it?

If you are about to use Struts on a project, are new to Struts and need dead tree documentation for those RTFM moments or are evaluating Struts for future projects, then you absolutely need this book.

If you are an intermediate Struts user, then this book would still be very useful to you and I can certainly recommend it.

If you are an experienced Struts user, then you've almost certainly exchanged emails with James or Kevin, on the Struts mailing list, so you can make your own mind up!

Table of Contents

  1. Struts in Context
  2. The Model-View-Controller Design Pattern
  3. Hello World!
  4. HTTP Protocol
  5. JSP, Taglibs and JSTL
  6. The Sample Application
  7. View Components
  8. The Controller
  9. Model Components
  10. The struts-config.xml File
  11. How the Struts Tag Libraries Work
  12. Struts HTML Tags
  13. Struts Bean Tags
  14. Struts Logic Tags
  15. The Nested and Template Struts Tag Libraries
  16. The Struts Tiles Tag Library
  17. DynaForms and the Validator
  18. Using Struts with Enterprise Java Beans
  19. Using Struts with Web Services
  20. Building, Deploying and Testing Struts Applications


You can purchase Struts Kick Start 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.
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • Struts? (Score:2, Funny)

    by Anonymous Coward on Tuesday December 31 2002, @11:38AM (#4988708)
    Why learn a whole new framwork? A combination of FrontPage and MS Access will do wonders for you - MS Access will even make the VB Code for you after you use the easy drop down utilities to create macros. From there, if you really need more, it is a simple step to port it over to MS SQL Server 2000, which is much, much more enterprise scalable than PostGreSQL or MySQL.
    • Re:Struts? by MaxwellStreet (Score:3) Tuesday December 31 2002, @11:45AM
    • Heh by autopr0n (Score:2) Tuesday December 31 2002, @04:38PM
      • 1 reply beneath your current threshold.
    • 1 reply beneath your current threshold.
  • by mschoolbus (627182) <travisriley@gmai l . c om> on Tuesday December 31 2002, @11:39AM (#4988718)
    Without Struts, my project at work would be about 100 times more difficult than it already is.

    I think Struts has a very bright future...
  • MVC (Score:2, Funny)

    by jimmyCarter (56088) on Tuesday December 31 2002, @11:41AM (#4988729) Journal
    That's simple man.. Al Gore invented the MVC.
    • Re:MVC by FarkinIceHole (Score:1) Tuesday December 31 2002, @04:16PM
    • Re:MVC by jimmyCarter (Score:1) Tuesday December 31 2002, @12:27PM
    • Re:Not quite tired yet.... by volsung (Score:1) Tuesday December 31 2002, @01:27PM
    • Re:MVC by ErikZ (Score:2) Tuesday December 31 2002, @02:05PM
      • Re:MVC by Malcontent (Score:2) Tuesday December 31 2002, @04:57PM
        • Re:MVC by ErikZ (Score:2) Tuesday December 31 2002, @05:43PM
          • Re:MVC by Malcontent (Score:2) Tuesday December 31 2002, @07:06PM
            • Re:MVC by ErikZ (Score:2) Wednesday January 01 2003, @12:11AM
              • Re:MVC by Malcontent (Score:2) Wednesday January 01 2003, @12:30AM
                • Re:MVC by ErikZ (Score:2) Wednesday January 01 2003, @08:56AM
                  • Re:MVC by Malcontent (Score:2) Wednesday January 01 2003, @01:26PM
                  • Re:MVC by ErikZ (Score:2) Wednesday January 01 2003, @05:02PM
                  • Re:MVC by Malcontent (Score:2) Wednesday January 01 2003, @11:46PM
                  • Re:MVC by ErikZ (Score:2) Saturday January 04 2003, @01:07PM
    • Re:MVC by Malcontent (Score:1) Tuesday December 31 2002, @04:55PM
    • 2 replies beneath your current threshold.
  • Little nitpick (Score:4, Informative)

    by FortKnox (169099) on Tuesday December 31 2002, @11:41AM (#4988731) Homepage Journal
    What is Struts?
    Struts is a framework for developing web applications. It is a distilation of the current set of known best practices into a working code set that can be extended to meet almost any web application requirements. It part of the Jakarta Project at the Apache Software Foundation.


    Struts is a Java/J2EE based framework. Although you could change it to use with other languages, it has taglibs and other features that are pretty much Java only.

    Why such an influx of Struts books? Its becoming quite the standard in the Java/JSP+servlet world. J2EE developers are still being hired (hear that unemployed CS people?), and have been strong through the IT drought, and Struts experience is an even bigger plus.
  • No idea what it does (Score:3, Insightful)

    by dnoyeb (547705) on Tuesday December 31 2002, @11:44AM (#4988754) Homepage Journal
    I still have NO IDEA what struts does. the struts website is not helpful in a brief overview. Saying it helps develop web applications is a joke. What does it replace because I can develop web apps without struts.

    Should I be using it? Im too unknowledgeable to even know what question to ask. I use EJB, and I have a webapp. I'm just baffled.
  • Struts is great, but... (Score:4, Informative)

    by General_Corto (152906) on Tuesday December 31 2002, @11:45AM (#4988762)


    I've been working on a reasonably sized project for some time now (still undercover, so can't go into details)... I'd been looking for a good framework to use, and Struts looked like it fitted the bill.



    Until I started dealing with the display (view) side of things.


    Getting to grips with the Action and ActionForm stuff is simple, and I think that anyone could do it. However, because they expect you to use all the usual standard stuff (taglibs, etc), building new taglibs and dealing with that was going to be a nightmare.


    Also, the HTML taglib, when told to output XHTML only, doesn't work. tags like the BASE tag aren't closed properly.



    Fortunately, I'd been looking at using Tea earlier on (Jason Hunter uses it at servlets.com [servlets.com]). Someone on the tea mailing list posted a link to a very useful article on using Struts for the backend of a web app and Tea for the front end. You can find it here:



    http://www-106.ibm.com/developerworks/library/wa-t ea1/ [ibm.com]

    http://www-106.ibm.com/developerworks/library/wa-t ea2/ [ibm.com]


  • java server faces (Score:2, Insightful)

    by rhyd (614491) on Tuesday December 31 2002, @11:52AM (#4988825)
    i thought these [sun.com] were going to replace struts sometime soon...
  • What the big deal with Struts... (Score:1, Interesting)

    by Anonymous Coward on Tuesday December 31 2002, @11:55AM (#4988846)
    Don't get me wrong, Struts is great and I am currently using it in my applications... But, I have to ask, what the big friggin' deal with struts - why all the hype...

    Strust is just an implementation of what has already been developed by several companies - I will use Apple as an example. The same sort of thing is done with WebObjects in that the HTML from end and back end Java (or Obj-C) is linked with the need to create any real glue to connect them - it just sort of does it for you - with a nice IDE I might add.

    WebObjects (like Struts) allows a developer to connect front end HTML to a server and pass data back and forth so that it's easier to deal with on the server...

    Okay so why the rant? Well do you really hear about WebObjects being used all that much, NO! The reason (outside of the fact that when it was a NeXT product it use to cost a forture) it that the learning curve is wicked steep. That is where I see Strust going, it's a great technology, can do all sorts of cool stuff, will ease development but requires some time to get ones head around how it works.

    I have seen more than a few projects that claim they use Strust when in fact they use maybe 5% of Strust and still need to use code to glue the front and middle tiers together. It's a real shame that we do not have really nice editor integration - ya ya, I know a few editors have the integration but face it folks, they all suck.

    What we need is one of the big guns to step up to the plate and really integrate (and support) struts integration *wink wink* Borland...

    Just my .02
  • ok folks (Score:2, Insightful)

    by Anonymous Coward on Tuesday December 31 2002, @12:00PM (#4988886)
    say it with me now ...

    "web-work is monkey-work"
    "web-work is not amazing"
    "web-work takes a pea sized brain"

    i should know - i do web work. because it pays.
    because some bunch of fools decided to pay me for
    it does not make it clever. because some bunch of
    fools decided to pay You for it definitely doesn't
    make it clever. step back and look at what you
    do and then tell yourself there is anything
    remotely complex in there. there isn't. its
    crap. its not scottish its crap. quit selling
    me books about crap. quit pushing your crap on
    everyone else. crap crap crap crap crap.
    • Re:ok folks by fraxas (Score:2) Tuesday December 31 2002, @12:16PM
    • 2 replies beneath your current threshold.
  • MVC... (Score:2)

    by blamanj (253811) on Tuesday December 31 2002, @12:11PM (#4988962)
    ...or model/view/controller, was invented by Trygve Reenskaug, and first appeared in Smalltalk at Xerox Parc.
    • 1 reply beneath your current threshold.
  • Is it just me...? (Score:3, Insightful)

    by Malic (15038) on Tuesday December 31 2002, @12:21PM (#4989065)
    ...or is it that Struts, JavaServer Faces and MVC methodologies merely enforce good coding techniques/styles that one should be using anyway? Regardless of if you are using PHP, Perl, etc.

    Or is there something more here?

    Sometimes I think Java, OO and other development technologies are like grammer school teachers hovering over our heads saying, "Now, we *know* you are going to be sloppy if left on your own, so are going box you in so that you CAN'T do those sloppy things."

    Except that you still can. VERY easy to understand and maintain applications can be coding procedual languages. VERY difficult to understand and maintain applications can be written in OO languages.

    But I digress... by nature.
  • What's not so good? (Score:3, Interesting)

    by Brummund (447393) on Tuesday December 31 2002, @12:22PM (#4989070)
    Just one niggle, and it's more of a programming style issue, but in their example code they have references to their business objects. They explain that it is important to separate out business logic from action logic, which it is, but then proceed to use their business object within the action.



    Hm. I'm not quite sure I follow you here. I haven't read the book, only your review, and I'm a bit puzzled by your statement regarding business objects in actions.


    Is it so that the example code for the actions contain business logic directly, or do they use business objects without wrapping them in controllers (like a session bean)


    If they're using session beans or controllers in the actions, I can perfectly understand that. You have to use the business logic somewhere. :-)


    On my current project, we have a (yuck) flash-client (using macromedia's Flash Remoting MX, btw. nice thing, saves a lot of time usually spent on devicing your own xml-based protocol to communicate with the flash client) . The flash client accesses a standard java class/bean. This bean contains code to massage the output from a session bean to simple data structures more suitable for a flash client (and programmer. Ok, low blow. :-)


    The session bean acts as an facade to all the functionality required by/provided to the client (authentication, fetching and updating data etc.) The system has about 10 session beans and quite a few entities.


    We've used this approach before, and when we had to add some new types of clients, we only have to add a bean convert to/from client requests and the controller (session bean).
    (At first, we only developed a Flash client. Later, we added a SMS client and a web client.)

  • Struts 1.1 (Score:1)

    by Free Heel Skier (466717) on Tuesday December 31 2002, @12:26PM (#4989100)
    Struts 1.1 is currently in Beta3, and it is going to fill in many of the gaps where the previous releases of Struts was deficient. I have been developing in struts for quite a while now (almost 2 years), and have had to desing a couple of patterns to make some things happen. This should all be fixed.

    Struts 1.1 has added nice features like Dynamic Action Forms, integration with JAAS for request level authorization, and separation of functionality through modules.

    If you have not previously used Struts this may not mean anything to you. Trust me when I tell you that these advances will be very welcomed by Struts users. I higly reccomend learning Struts, however the existing books only cover previous versions. If you are looking into using Struts on a future project you may want to check out the upcoming release.

    Life is like an elevator, sometimes you get the elevator and sometimes you get the shaft.

    • Re:Struts 1.1 by blackbearnh (Score:1) Tuesday December 31 2002, @07:48PM
  • Husted book (Score:1, Informative)

    by Anonymous Coward on Tuesday December 31 2002, @12:41PM (#4989212)
    Actually, what I would like to see is a review of the Ted Husted book Struts in Action [manning.com] , ISBN 1930110502. It was listed as not published yet yesterday at amazon.com, but is now listed [amazon.com] as "usually ships in 13 to 14 days." It is available sooner at bn.com [barnesandnoble.com] or direct from the publisher. [manning.com] Husted is one of the more well-known Struts gurus, and I think his book has been much more anticipated than the one reviewed.

    One thing I like is that the publisher, Manning Publications [manning.com], lets you buy a PDF version of the book for half price. They will also deduct the cost of the PDF version if you decide to buy the tree version later. There are a couple of sample chapters [manning.com] online, one about integration with Tiles and another about validation. The sample chapters I have read seem very complete and well-written.

    I know this post sounds like an advert for the book, but I'm not associated with the book in any way. I'm just a Struts developer who's been waiting for a good Struts book to come along, and the Husted book looks like it might be the one.
    • Re:Husted book by blackbearnh (Score:1) Tuesday December 31 2002, @07:51PM
    • 2 replies beneath your current threshold.
  • looks like the abstration in asp.net (Score:2, Insightful)

    by xdrone (597762) on Tuesday December 31 2002, @12:54PM (#4989296)
    his looks like the abstraction used in asp.net which changes the interaction of web pages to an event based model rather than just posting back forth and checking user values. (correct me if i'm wrong)

    it's a big step forward cleaning up web programming. i'm sure it will come to php sooner or later, although i'm happy with old stylee.
  • by brad.hill (21936) on Tuesday December 31 2002, @01:17PM (#4989465)
    XMLC and Barracuda offer a nice alternative to Struts without all the crap of JSP and the enormous clusterf**k single XML file that Struts uses.

    XMLC enforces a nice clean seperation of code and presentation data and has a great framework (Barracuda) that does everything Struts does and more. (polymorphic event dispatch and real OO event handling, for example)

    Check it out at www.enhydra.org [enhydra.org]. There's also a great book out on XMLC, if you prefer paper.
  • similar to CSS? (Score:2)

    by miltimj (605927) on Tuesday December 31 2002, @01:18PM (#4989470)
    I've never used Struts, and my web apps are almost all Perl/CGI, but I'm still curious (of course)..

    Would this analogy be reasonably accurate?

    Struts : web apps as Cascading Style Sheets : HTML ?
  • XSP vs. JSP?? (Score:1)

    by Hurricane_Bill (96738) on Tuesday December 31 2002, @01:23PM (#4989516)
    Can anybody help explain the difference, as well as pro's/cons of using XSP vs. Java?

    I've been thinking about learning JSP for web development but recently I've started looking at Apache Cocoon which is an XML framework, built on java. It uses XSP to call java business logic which then gets rendered in html. This looks very similar to JSP (except for the XML stuff).
  • Struts ported to PHP (Score:2, Interesting)

    by tetranz (446973) on Tuesday December 31 2002, @01:55PM (#4989728)
    Phrame [ttu.edu]
  • by javabandit (464204) on Tuesday December 31 2002, @02:08PM (#4989837)
    I have used Struts, and personally, I really don't see anything special about it. While I agree that having "scriptlets" in your HTML is generally bad form, I have similar problems with putting Java-centric tags in presentation code as well.

    Struts, Java Server Faces, Servlets... All of these tools do not solve a real issue at hand, which is that when it comes to internet/HTML applications, the presentation layer should not tie you to any language, or to any language-specific framework.

    I should be able to write a "View" that simply Looks at a standard XML-based model, and construct my page from that. Without having to put any kind of Java or Java-based tags in my code. XSLT comes far in doing that, but has a few shortcomings.

    The missing piece is a standardized interface upon which posts/gets etc... can be performed without regard to the View, or to the language used in the application server. This interface should of course handle necessary things such as session management, authentication, and the like. This way, we could change out our underlying backend without having to change the presentation code at all.

    This is where I give CORBA a lot of props. It definitely had some problems, but it was a wonderful intermediate interface that didn't care who its client was. As long as the client spoke IIOP... life was good.

    The same should be done for web interfaces. The presentation layer should not care beans about the backend... expect that the container is aware of a common/neutral interface. No vendor specific tags. No language-specific tags. No proprietary garbage that ties you to any particular container.

    XML, XSLT, XSD are great. Java is great. All these technologies are great. But the lack of a common interface/framework which seamlessly ties them together for web applications is the real problem.
  • by Apoptosis66 (572145) on Tuesday December 31 2002, @02:10PM (#4989848)
    We are doing a rewrite of our web application, and have pretty much decided to use struts. However, we can not decide on what to use for object persistance and caching. We have ruled out CMP for performance reasons, BC4J is a option but many of us don't like being tied to Oracle. Are there any open source frameworks for doing this that someone has used successfully and are happy with? Object Relational Bridge? Torque? We could really use some outside input on this.
  • which java where? (Score:2)

    by tunesmith (136392) <{siffert} {at} {museworld.com}> on Tuesday December 31 2002, @04:09PM (#4990545) Homepage Journal
    Here's what I don't understand - what jakarta technologies are mutually exclusive with each other? I did apache jserv development for a couple of years and I want to update by using java for a large scale personal project. My brain is tumbling around several options:
    1) struts
    2) tomcat/jetty
    3) EJB (jboss/resin)
    4) enhydra

    So, what can be used with what? Can #1-#3 be all used together? I mostly just want to gain wide experience to help the old resume.
  • by codepunk (167897) on Tuesday December 31 2002, @05:59PM (#4991176) Homepage
    The problem with web development in java is two fold. It is slow and not a very productive environment. PHP, NET and Perl will always be more productive. Now the PHP ported struts framework, now we are talking.
  • Try Tapestry (Score:2)

    by Tom Davies (64676) <tomdavies@exemail.com.au> on Wednesday January 01 2003, @06:23AM (#4993196) Homepage
    http://sf.net/projects/tapestry

    This is *much* nicer than struts/JSP. It makes producing reuseable components much easier, and abstracts servlets very nicely, while still allowing access to the bare meal if needed. And it has the best documentation of any OSS project I've seen!

    Tom
  • by red elk (597133) on Thursday January 02 2003, @09:45AM (#4998325)
    As someone who has recently moved over to Java from other languages, Struts has really helped me understand MVC and the power of XML to control large applications. Servlets are extrememly powerful and robust and very handy to be controlled from one line of code in the config.xml... If you want to see some of cooler things you can do with struts, check out keyboardmonkey's site [keyboardmonkey.com]- servlet tree hierarchy... very handy.

    For all those who have never tried out the struts framework- give it a chance... and you don't need a $50 book to try it out. Try out Ted's Tutorials and learn through example!


    www.startvino.com [startvino.com]
  • Re:Struts is GARBAGE (Score:4, Informative)

    by Lysol (11150) on Tuesday December 31 2002, @02:55PM (#4990142)
    Not true at all. I've been following Struts for a *long* time and depending on the project it can make a huge difference. Sure, you can code page to page, embed the logic wherever and move on your merry way. But adverse things will definitely start to happen when:

    1. you are no longer 'the man' and the mgmt rolls in the html guy(s)/gal(s). most html people can deal with <xml style markup> than <%java scriptlet%> stlye <%blocks%> (i won't even get into logic flow in scriptlet blocks). separation of presentation logic from biz logic; speaks for itself. and it's possible with scripting languages, but tough.

    2. you want to extend the app. 'oh, but marketing want's to have their server also come in on that url that you did last year'. true, you could accomplish extension well with scripting language, but the delegation with struts/MVC us much cleaner and more maintainable.

    3. you want to debug/qa. struts is tested and kid approved. i'm going thru something right now where our system has bugs and no one really knows cuz different people have worked on each others code and did everything differently. and even on a huge project in the past i had done, it was still hard for me to figure out flows and such when they were scripted from page to page. a unified framework helps resolve those differences in coding and thusly, easier to debug.

    And I'm sure there's even more things that I haven't listed. One issue to really consider is do you want a page to page thing - which is good for proof of concept, quick and dirty. Or do you want something you can live with for the next year or so? Using a framework like struts will make your long term much easier.

    For the biggest project I worked on, a major airline portal, we rolled our own MVC framework. This was prior to struts and yet in the end, the code was very similar. Their system runs on over 100 Sun CPUs and has been cranking away since they launched a few years back, without a major crash or anything.

    This stuff does work and the bigger the project, the better. It's a little tough to get in the beginning, but after you implement it, you start to see that it makes sense. I feel tho, it's definitely more of an 'enterprise' thing than a small 20 page site; altho, u could use it for a small site if you wanted, no problem.
    [ Parent ]
  • by blackbearnh (637683) on Wednesday January 01 2003, @12:33AM (#4992500)
    It was built using Userland Radio, and we haven't set up the RSS channels yet. I've been busy helping with the 1.1b3 Struts release... James
    [ Parent ]
  • 14 replies beneath your current threshold.