×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Struts Survival Guide

timothy posted more than 9 years ago | from the duct-tape-is-key dept.

Programming 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.

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.

cancel ×
This is a preview of your comment

No Comment Title Entered

Anonymous Coward 1 minute ago

No Comment Entered

113 comments

struts is a pig (-1, Flamebait)

avandesande (143899) | more than 9 years ago | (#8998552)

web applications created with struts are slow and memory hogs... you end up creating tons of objects even when you are doing something simple. It's really an OO academic exercise.

Re:struts is a pig (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998637)

Here's the flame for your bait - come back and post when you're writing real webapps, not paeons to your favorite teenybopper band, OK?

Re:struts is a pig (4, Funny)

Safety Cap (253500) | more than 9 years ago | (#8998923)

~ come back and post when you're writing real webapps ~.
Whatchu talking 'bout? PHP and MySQL should be enough for anyone: all the carbs and none of the "buzz" as the regular beer.

MVC development is convoluted and confusing, therefore it is slow and memory hoggish.

Feed the troll! (0)

Anonymous Coward | more than 9 years ago | (#8999141)

Come one people, feed the troll, feed the troll!

Re:struts is a pig (1, Interesting)

avandesande (143899) | more than 9 years ago | (#8998646)

Flamebait? There is a point where class creation is a form of redundancy (just the file naming creates redundancy). There is a point where you can go overboard with OO and struts is it.

Re:struts is a pig (1)

BigGerman (541312) | more than 9 years ago | (#8998711)

I'd say: variable creation is a form of redundancy as well. Numeric value pointing to a memory location should be enough for most of the people.

Re:struts is a pig (0)

Anonymous Coward | more than 9 years ago | (#8999026)

I would be interested in seeing an exposition on server.xml for Tomcat. JNDI and JOCL are two FLAAs (Four Letter Array Acronyms) that strangely, systematically, even mysteriously, undocumented on the broader internet. Smells like...business model
Which is fine; great that they're making a buck somewhere. Please inform my professor so that maybe next semester he won't be giving death march assignments.
I can't complain about the collateral learning going on, though; it really is neat stuff.

Re:struts is a pig (2, Interesting)

Brando_Calrisean (755640) | more than 9 years ago | (#8999077)

He has a point - this is the number one complaint I hear from developers using Struts where I work. Minor modifications often result in a ridiculous amount of changes in other files.

How do JavaServer Faces compare? Anyone use them for a web application yet?

Re:struts is a pig (1)

Sqwubbsy (723014) | more than 9 years ago | (#8999920)

How do JavaServer Faces compare? Anyone use them for a web application yet?

Haven't built anything with them yet, but I've been throwing around the buzzword for a few weeks now.

Re:struts is a pig (4, Interesting)

nvrrobx (71970) | more than 9 years ago | (#8999151)

Have you ever made a large scale J2EE Webapp? If you can back up your statements, I'd love to hear it, otherwise your flamebait rating was warranted.

You have a few approaches you can do in these webapps. You can stick to JSP and Servlets. JSP's biggest downside: mixing Java code and markup together is messy and difficult to maintain. For a small scale site, this works out just fine.

One other option: Struts + Velocity. I opted for this approach in a large scale app I just wrote. It's not any slower than JSP, and the code is amazingly maintainable. The learning curve for new developers is kind of steep, but once they get used to it, they love it. xdoclet makes the job of maintaining the struts-config.xml pretty painless. Even if you don't want to use xdoclet, it's a pretty simple xml file.

There are other options also, TurboM2, Cocoon, etc. Struts just happened to fit what I was doing best.

Re:struts is a pig (2, Insightful)

Anonymous Coward | more than 9 years ago | (#8999517)

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.

Re:struts is a pig (0)

Anonymous Coward | more than 9 years ago | (#9003293)

Taglibs are a (cumbersome and overly verbose) syntactic sugar for scriptlets.

There are very good environments (Eclipse and others) that provide excellent tools for writing and debugging java classes. I am unaware of tools that do the same for JSPs - which, frankly, are a supremely overated technology.

All this worry about mixing html and code... what, are you guys writing pages using Slashdot-style HTML 3.2 from 5 years ago?

If you really want to seperate presentation from content, design your pages using CSS and XHTML 1.0 Strict. Your markup will be so simple that you can generate it from your servlet.

Re:struts is a pig -- downside?????? (0, Insightful)

fedor (598123) | more than 9 years ago | (#8999890)

Why is mixing Java-code and markup a downside?
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 ... 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......

Re:struts is a pig -- downside?????? (0)

Anonymous Coward | more than 9 years ago | (#9000071)

Agreed that Struts sucks.

However, try this:

Create your table as you explained.
Now create your table using a tag library.

Now do it on 25 different pages in your website.

1. The inclusion of a tag that does this (like JSTL for loops) is more readable, and easier to understand for presentation people that don't know Java.
2. The code is in one place (the tag library) and doesn't need to be copy-pasted 25 different places, and become a mainenance nightmare if something changes...

Raw Java code in JSP pages should be avoided, as it sucks.
Struts sucks too - too many configuration files. Way too complicated for what it is. JSF looks like it may be a step in the right direction... but not enough.

Re:struts is a pig -- downside?????? (1)

chez69 (135760) | more than 9 years ago | (#9000327)

is one config file that hard? or 2 if you include web.xml.

i maintain a very large struts application and struts has made everything maintainable.

Re:struts is a pig -- downside?????? (2, Interesting)

takotech (648308) | more than 9 years ago | (#9000094)

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.

But say you wanted to do that several times over different tables with different size results. If you embed a java for loop in your JSP to accomplish this, you have to basically copy and paste your code where ever you want to repeat this behavior.

Tags allow reuse. Copy-and-paste is not reuse.

The problem with scriptlets is that they are so easy to use. They are great for prototyping but, as is often the case in software, prototypes soon become production applications.

Re:struts is a pig -- downside?????? (1)

fedor (598123) | more than 9 years ago | (#9000397)

Yeah right.... So, in your opinion I have to create a tag instead of a simple for-loop (that anyone can read) because I may not copy-paste a for-loop. Every structured program contains loops and stuff (Dijkstra), so why should we add another custom abstraction layer, and (and that's the other downside) a new scope?

Re:struts is a pig -- downside?????? (1)

takotech (648308) | more than 9 years ago | (#9004352)

In this case, you are not tagging the for loop. You are tagging a specific browsing behavior(view N things at a time). And even if it were a simple for loop, using tags instead of scriptlets exposes iteration variables that other tags might want to use whereas you cannot easily get at local scriptlet variables.

My point is tags are a good thing and should be used when possible. Scriptlets are the main reason people say "JSP sucks cause you can still embed Java in your HTML". Tags encourage reuse. Scriptlets encourage haters

Re:struts is a pig -- downside?????? (1)

fedor (598123) | more than 9 years ago | (#9004669)

Using tags is the same as indirectly embedding java in your HTML. The only difference is that you have to open more files (an XML-configuration, a java-class) to see what it's behavior is. When using just java embedded in your HTML you have everything in just one file.

Be honest, moving a so called scriptlet to a class, writing a descriptor-file and add some
new syntax (a new tag) to the mark-up-language
is a lot of work. A simple piece of java-code is easier to maintain than all this framework-stuff,
just because it's less code.

Adding some simple functionality is a lot of
work.

And what 's the difference between:

<%=this.is.my.Tag.getHTML()%>

and some fancy XML-syntax!?

Isn't <%xyzzy%> xml-compliant?

When re-use is an issue, you can always use jsp-includes :) And when using tags you also
copy/paste the calls to the tags.

Do PHP-taglibs including XML-config exist?

Struts + Velocity (2, Interesting)

jefflinwood (20955) | more than 9 years ago | (#9000402)

I agree with you that Velocity [apache.org] is the way to go for Java web applications. We use Velocity instead of JSP for the web presentation layer.

Velocity also excels at being a general purpose templating language - sure, JSP Expression Language gives you some of what Velocity does, but you can use Velocity to process any text, anywhere in a Java application.

Re:struts is a pig (1)

avandesande (143899) | more than 9 years ago | (#9000627)

Yes i have. But judging by the number of posts on this book review most other people agree with me too.

ZING! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998555)

Suck a Boot!

Congratulate me (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998559)

For my ferst poste.

Re:Congratulate me (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998606)

Congratulations, 3W3 PH41\ 1T!!!!!

FP! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998564)

OMG MY FIRST FP!

Re:FP! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998613)

OMG MY FIRST FP!

You mean your first FAILURE!?

Nice try, now move to the back of the line. Next...

FP! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998578)

Fifth post!

Re:FP! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#9000251)

YOU even FAILed the fIfTh post!

here we go (-1, Flamebait)

Anonymous Coward | more than 9 years ago | (#8998590)

"jakarta"

great, more jobs going away.

when will we wake up and bomb India and other useless nations back into the stone age?

better survival guide (2, Informative)

primus_sucks (565583) | more than 9 years ago | (#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" (3, Interesting)

persaud (304710) | more than 9 years ago | (#8998838)

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 architectural basis of Spring is an Inversion of Control container based around the use of JavaBean properties. However, this is only part of the overall picture: Spring is unique in that it uses its IoC container as the basic building block in a comprehensive solution that addresses all architectural tiers.

... The concept behind Inversion of Control is often expressed in the Hollywood Principle: "Don't call me, I'll call you." IoC moves the responsibility for making things happen into the framework, and away from application code. Where configuration is concerned this means that while in traditional container architectures such as EJB, a component might call the container to say "where's object X, which I need to do my work", with IoC the container figures out that the component needs an X object, and provides it to it at runtime. The container does this figuring out based on method signatures (such as JavaBean properties) and, possibly, configuration data such as XML ..."

And if you get tired of J2EE quirks (-1, Flamebait)

Anonymous Coward | more than 9 years ago | (#8998610)

there's always an easy way [zdnet.co.uk] to get your app up and running before the deadline slips

I have having trouble understanding Struts (4, Interesting)

Muda69 (718162) | more than 9 years ago | (#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 !

SCO WINS!!!! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998704)

ne more crippling bombshell hit the already beleaguered Novell community when IDC confirmed that Netware
market share has dropped yet again, now down to less than a fraction of 1 percent of
all servers. Coming on the heels of a recent Netcraft survey which plainly states
that Netware has lost more market share, this news serves to reinforce what we've
known all along. Novell is collapsing in complete disarray, as fittingly exemplified by
failing dead last [samag.com] in
the recent Sys Admin comprehensive networking test.

You don't need to be a Kreskin [amdest.com] to predict
Novell's future. The hand writing is on the wall: Novell faces a bleak future. In fact there won't
be any future at all for Novell because Netware is dying. Things are looking very bad for Novell. As
many of us are already aware, Netware continues to lose market share. Red ink flows like a river of blood.

Corel Netware is the most endangered of them all, having lost 93% of its core developers. The
sudden and unpleasant departures of long time Corel developers Jordan Hubbard and Mike Smith
only serve to underscore the point more clearly. There can no longer be any doubt: Netware is dying.

Let's keep to the facts and look at the numbers.

Netware Admin leader Theo states that there are 7000 users of Netware Admin. How many users of ConsoleOne
are there? Let's see. The number of Netware Admin versus ConsoleOne posts on Usenet is roughly in ratio
of 5 to 1. Therefore there are about 7000/5 = 1400 ConsoleOne users. Corel Netware posts on Usenet are
about half of the volume of ConsoleOne posts. Therefore there are about 700 users of Corel Netware. A
recent article put Novell Netware at about 80 percent of the Netware market. Therefore there are (7000+1400+700)*4 =
36400 Netware users. This is consistent with the number of Netware Usenet posts.

Due to the troubles of Word Perfect, abysmal sales and so on, Corel is going out
of business
and will probably be taken over by Novell who sell another troubled OS. Now Novell
is also dead
, its corpse turned over to yet another charnel house.

All major surveys show that Netware has steadily declined in market share. Novell is very sick and
its long term survival prospects are very dim. If Netware is to survive at all it will
be among OS dilettante dabblers. Netware continues to decay. Nothing short of a miracle could
save it at this point in time. For all practical purposes, Netware is dead.

Does it include a 'Pronunciation' chapter? (5, Funny)

webusr2 (774977) | more than 9 years ago | (#8998721)

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."

Re:Does it include a 'Pronunciation' chapter? (1)

dartboard (23261) | more than 9 years ago | (#8999259)

Who cares? Your "extreme" case sounds perfectly reasonable to me, and got the point across, didn't it?

Re:Does it include a 'Pronunciation' chapter? (1)

iabervon (1971) | more than 9 years ago | (#8999889)

Actually, the operation of back-formation, where a singular noun is used as if it were plural and then a final 's' is removed to form an "even more singular" noun is a common part of language change. While you're complaining about "Strut", you should also complain about "cherry" and "asset" (from "cherries"/"cherise" and "assets"/"asetz"). English nouns ending in 's' just don't survive unless there's no way to think of them as a group, especially if there's no good term for what it would mean if resingularized.

Jakarta Struts (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8998792)

Is that what holds up the Petronas Towers?

No please... (-1, Troll)

Anonymous Coward | more than 9 years ago | (#8998815)


Struts is such a big over-engineered pile of shit..

Re:No please... (0, Flamebait)

kin_korn_karn (466864) | more than 9 years ago | (#8999088)

I'll stake karma on what you said:

"Struts is such a big over-engineered pile of shit."

Re:No please... (1, Funny)

6Yankee (597075) | more than 9 years ago | (#8999725)

"Struts is such a big over-engineered pile of shit."

I was going to mod this Insightful, but then thought, nah. You see, it doesn't go quite far enough. I've used Struts, once, and that was once too many. Repeat after me, children:

Struts is the festering soiled nappy of the bastard spawn of Satan.

Ugh. Now wash your mouths out with soap.

Re:No please... (4, Informative)

slamb (119285) | more than 9 years ago | (#8999800)

"Struts is such a big over-engineered pile of shit."

Compared to what? Pure JSP? Maybe if you have like two pages total, but if you have any more than that you'll discover that:

  • You've got huge chunks of Java code in your JSP that make little sense there. You've got two conceptually separate things there - the actions your code is taking and how it's presented. JSP makes sense for the presentation, but not for the real work.
  • You're either making a lot of redundant pages or redirecting back and forth in weird ways.
  • You're having to do a lot of work to keep passing users' data back to them in a HTML form when you have a validation error. I.e., when the user fills out a huge form and has an error halfway through. Most of the values need to be defaulted to their previous ones.

If you set out to solve these problems, you'll inevitably end up at struts. It may do other things (don't know; I haven't ventured in that deeply), but it does these in about as simple a way as anyone could.

I challenge you to find any significant amount of redundant code in a project of mine that uses struts: mb. Description here [slamb.org], browse the code here [slamb.org]. There's not a lot of code there, and struts is largely responsible.

Internally, struts may be hugely overengineered...but I, as a user, don't care. It helps me keep my applications more terse and well-organized. (Much more maintainable than what I wrote before.)

Re:No please... (1)

kin_korn_karn (466864) | more than 9 years ago | (#9000120)

I'll say one good thing about struts: the validator kicks ass.

I looked at your code. It looked good. 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.

Re:No please... (1)

chez69 (135760) | more than 9 years ago | (#9000381)

I work on a huge internal application, we use struts everywhere.

a well written struts app is very easy to find your way around, especially if you use a good ide.

Re:No please... (2, Insightful)

slamb (119285) | more than 9 years ago | (#9002161)

I looked at your code. It looked good.

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.

Re:No please... (2, Interesting)

toriver (11308) | more than 9 years ago | (#9001345)

Compared to what?

Any basic Model 2 architecture implementation with some custom tags (e.g. from JSTL) and a template set.

If you want "event driven" it should be built-in from the start, like with ASP.Net's "code behind" logic.

(Short summary of Model 2 architecture: A "front controller" servlet which dispatches to JSPs based on state. Preferrably via a template that does includes for the selected content. All JSPs are "hidden" under WEB-INF to prohibit direct access from the outside. Optinal: Lower layers (data access, EJBs, CORBA, SOAP) isolated via the BusinessDelegate pattern and value objects.

Re:No please... (1)

slamb (119285) | more than 9 years ago | (#9002240)

(Short summary of Model 2 architecture: A "front controller" servlet which dispatches to JSPs based on state. Preferrably via a template that does includes for the selected content. All JSPs are "hidden" under WEB-INF to prohibit direct access from the outside.

How is struts not that? I tend to use it as something that does just what you've described, plus the validator bit for the HTML forms. There may be additional parts of it that do other things, but they're clearly not necessary because I'm not using them.

Could you give me a specific example of another Model 2 architecture and how it is simpler than struts?

Re:No please... (1)

tedgyz (515156) | more than 9 years ago | (#9002583)

I have built a successful ($450K subscription revenue in 6 months) production app using Struts. Struts has a steep learning curve, but once you get over the hump, the payoffs are enormous.

I am now embarking on a second app built on the technology of the first one. I spent the last 2 months rewriting much of the JSP side of things, having finally learned how to do things the right way.

I feel the biggest hole to fill in the literature is the tag libraries. I nearly killed myself learning how to properly extend and implement a tag library. The community needs a whole book just covering the usage and customization of Struts tags.

Having survived that ordeal, I now have nearly 100% scriptlet-free JSP. Scriptlets in JSP is like cancer. You don't realize how badly it is infected until you try to remove it. I have dubbed the term "page global variables", in reference to the usage of variables defined in one JSP and then used by included JSP fragments. They are as insidious as good old-fashioned C globals.

Re:No please... (1, Informative)

Anonymous Coward | more than 9 years ago | (#9002936)

What did struts help you out with?

There's lots of MVC jibba jabba from Struts foo's, but you don't need Struts for MVC, and using Struts means you have to put up with its many questionable design choices:

1. Singleton Actions.
I've read that this was due to performance, but that seems rather silly. If instantiating a form bean and populating it via reflection is acceptable, why is creating an instance of an Action a problem?

2. Decoupling Actions and Form beans.
Frankly, the seperation of Action (behavior) and Form (data) seems anti-OO. Doesn't anyone else cringe when they see the following standard struts idiom?

public ActionForward doStuff(ActionMapping m, ActionForm form, ....) {
MyFormType myForm = (MyFormType) myForm; .... myForm.getAttributeX();

}

3. Reflective population of form beans, no mechanism for describing how to create a form in a valid state.
Bad idea. No compile-time checking, nothing resembling pre-condition declarations, and consequently code that is very sloppy and difficult to test (how many possible states does a form bean have?). Also, potentially insecure, particularly when a Form bean is used for only some of its attributes by an Action. What happens if someone builds a "hostile" http request?

4. XML config.
I could never understand this. What's the value of defining the action forwards and dyna action forms in another language (ie the config XML) that is not programmatically accessible from the Java code? Its not like you can change struts config without changing the corresponding Java.

The Jakarta Strut (-1, Troll)

stratjakt (596332) | more than 9 years ago | (#8998816)

is used to describe the stiff legged, uncomfortable walk of a man in the waiting room of the free clinic, his penis belching what feels like liquid fire, after a trip to "exotic" Indonesia.

Maypole (3, Interesting)

bnavarro (172692) | more than 9 years ago | (#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 (3, Insightful)

kin_korn_karn (466864) | more than 9 years ago | (#8999138)

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.

Re:Maypole (0)

Anonymous Coward | more than 9 years ago | (#8999174)

It compares like this: it hurts less to shove a Maypole up your ass than it does to code in Struts.

Re:Maypole (1)

jeanlo (84448) | more than 9 years ago | (#9000029)

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.

Re:Maypole (1)

Gortbusters.org (637314) | more than 9 years ago | (#9004170)

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?).

THREAD CLOSED (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#8999134)



*** This thread is marked as CLOSED ***
*** Please move on to another topic ***


DIY (1)

seanmceligot (21501) | more than 9 years ago | (#8999264)

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 (3, Insightful)

radish (98371) | more than 9 years ago | (#8999849)

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...

Re:DIY (0)

seanmceligot (21501) | more than 9 years ago | (#9000841)

transactions - use JDBC.
sessions - use a database or create server that acts as shared memory.
stickyness - don't do it, or have a dedicated server when you need it.

Anyway, the point is, it will make you smarter if you learn how to do this stuff your self. Once you get good at it, it won't seem like magic.

I've written my own jsp-like server [nongnu.org], my own database [sourceforge.net]. My own bean-managed persistence framework (before j2ee).

I once shocked my colleges by running our application which usually runs in Weblogic in a simple RMI server which I wrote in a few hours.

It would take a long time to rewrite the entire J2EE spec or to rewrite Struts, but it doesn't take long to write something that does what my own application needs.

And no, I don't write simple apps.

Re:DIY (1)

Marcus Green (34723) | more than 9 years ago | (#9000964)

Well I guess that makes you a very, very clever person. But for the rest of the population of just fairly bright people, frameworks can be very handy indeed.

Re:DIY (1)

aled (228417) | more than 9 years ago | (#9003422)

I'm the cleverest fastest supercoder programmer, but unfortunately I'm the laziest.

Re:DIY (2, Interesting)

graveyhead (210996) | more than 9 years ago | (#9002900)

It would take a long time to rewrite the entire J2EE spec or to rewrite Struts, but it doesn't take long to write something that does what my own application needs.
The arrogance!

There are major flaws with this line of thinking. I just started a new job where the developer I replaced shared your philosophy. It was a disaster. He wrote a half-assed persistent object model tied heavily to our application and MySql. Now that he's gone:

* Nobody can update his code on schema changes
* The code has bugs, we aren't digging through 1000+ lines of shash to figure it out..
* There isn't a single javadoc comment in the whole project.

So, by your logic I should throw out his work and write it again. What utter BS. Apache Torque [apache.org] (a Jakarta project) does a *far* better job with a cleaner interface than you can write, I guarantee it. Plus, we can upgrade Torque itself (if there is any need... doubtful). The new object model now can support any database and is not tied at all to the application. Even if I leave the company, someone else *will* be able to maintain it: change XML schema, rebuild, voila new object model.

It really sounds like you're grepping for a justification for re-inventing the wheel. Take the time to learn the frameworks. Some of them (esp Jakarta stuff) will suprise you.

Re:DIY (1)

Ikari Gendo (202183) | more than 9 years ago | (#9004041)

He wrote a half-assed persistent object model

But you repeat yourself!

Seriously, you folks who are so infatuated with ad-hoc halfassed hierarchical databases (sorry, "persistent object models") should take your own damn advice about "reinventing the wheel" and try using relational database management systems.

Re:DIY (0)

Anonymous Coward | more than 9 years ago | (#9000865)

You are probably one of those fools that have been taught you can't write good, flexible code and that some one else is better at it, and you are right... but just because you are one of those idiots, dont think others are like that too. There are very bright engineers that have lost their voice because some otehr fool write crap like struts and gives it away for free, so fools like you can look like a bright guy using it and crating a web application that any third grader can do just as well.

If apache approves, its ok if its crap (0)

Anonymous Coward | more than 9 years ago | (#9003631)

I frankly wasn't all that excited about struts.
What pisses me off is that whenever
the apache project approves an idea,
no matter how crappy, it gets a TON
of attention ... so even if the idea itself wasn't bad to begin with, it will turn to crap once
it becomes part of the apache project

don't get me wrong, the apache project has tons of great software, I just don't think struts is one of them

Too complicated? (4, Insightful)

cyberwitz (767170) | more than 9 years ago | (#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.

Re:Too complicated? (0)

Anonymous Coward | more than 9 years ago | (#9000603)

Or you can have the best of both worlds, ASP.NET.

Re:Too complicated? (0)

Anonymous Coward | more than 9 years ago | (#9000695)

Complicated solution that can only solve simple problems?

Where do I sign up!

Re:Too complicated? (3, Insightful)

Anonymous Coward | more than 9 years ago | (#9000768)

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 and coldfusion are all fine and dandy if you don't use Linux, and you don't mind the premium you'll be paying for the rest of the product life. Coldfusion is worse, because you'll be the only one that can fix any problem that comes up.

Python is slow, but it's fast enough for just about anything most people want. It's like Perl without all the weird syntax. It's easier to learn and use than Perl. Need a web-app, use Zope instead of PHP, it's much easier to use and test.

For anything complicated, I use Java because it just works. I have code from 1997 that I haven't looked at or even recompiled, and it still runs just fine. It runs fast on all computers. The same basic language can be used to write applications for handhelds and phones. There are more libraries in Java than even Perl, and it takes less time to write software in Java because of it.

There really isn't a "right language for the job". That notion is as silly as saying that everyone should speak French to order food, Itallian to sing Opera, and English to talk business. It's just silly. You use a language because it's easy to understand, easy to use, and because a lot of other people use it. Any turing complete language can perform any task. If few people use the language, then you aren't going to get very much help or employment prospects from it.

So what do you need in a language?
One that performs well on as many systems as possible.
Easy to maintain code, even if it's not your code.
Can be used in many environments for many purposes.
Easy to code in.

Python fits the bill pretty well, but Java does even more so. I use Python when it is an issue of licensing, or when I'm doing an exercise. I use Java professionally, because if I leave this job, the company won't be in the situation they are in now. They have clients running on a mod_perl server that takes twice as long to add functionality to, and is at more of a stability risk to do so than it would be if the code base was in Java, as well as there are very few people they could have work for them considering that relatively a lot more people know Java than Perl.

I would recommend people actually use the more popular technologies unless there is good reason to stray away from them. You never know when you'll have to move on to a new position/company, and you don't want to get calls at all hours asking you questions about confusing technologies that are poorly documented.

There's an abundance of information about Java. It's a clean language. It runs on everyone's computer just the same. It's almost as fast as C code these days. It's free. The only thing to complain about is the licensing.

Re:Too complicated? (1)

red elk (597133) | more than 9 years ago | (#9003859)

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 little over a thousand bucks (which most companies can pay for) you can have a server like CFMX that is easy and can handle most siteloads. Java is such a lovely idea until you are bogged down for a deadline and you have to google up exception errors trying to figure out why your JavaMail hangs.

Coldfusion (0)

Anonymous Coward | more than 9 years ago | (#9004945)

Heh, 2 years ago we rewrote a major web application of our company (www.cv.lt) from scrach. We've been happy after that. It was written in coldfusion (on mysql), and it was crap. Way too many problems with no way to fix them, problems with coldfusion server crashing under linux under high loads and so on and so on. Now it's written with java/struts/postgresql.

--Coder

Check out spring... (4, Informative)

D-Cypell (446534) | more than 9 years ago | (#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.

Re:Check out spring... (3, Informative)

pbur (88030) | more than 9 years ago | (#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.

Re:Check out spring... (1)

aled (228417) | more than 9 years ago | (#9003446)

I kept reading good things about Spring but I would like to know how well it does in big projects.

just say no to struts (2, Informative)

Anonymous Coward | more than 9 years ago | (#9000023)

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 ... (3, Insightful)

tyrione (134248) | more than 9 years ago | (#9000142)

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? (4, Informative)

TapestryDude (631153) | more than 9 years ago | (#9001973)

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.

asp.net better than struts (1, Interesting)

Anonymous Coward | more than 9 years ago | (#9000188)

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.

Re:asp.net better than struts (0)

Anonymous Coward | more than 9 years ago | (#9002304)

You're right, I don't agree with you, mainly because you haven't backed up your claims with any actual arguments.

Seem to be a lot of Microsoft bots around at the moment.

Struts rocks! (1, Informative)

Anonymous Coward | more than 9 years ago | (#9000377)

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.

what one should use (0)

Anonymous Coward | more than 9 years ago | (#9000543)

There is really only one solution, "Fireant".

Career survival guide for Struts + J2EE developers (-1, Flamebait)

Anonymous Coward | more than 9 years ago | (#9000652)

This is the book [amazon.com] is the essential career survival guide for Struts and J2EE developers.

modw d0wn (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#9000815)

Www.anti-slash.org more stable things in Distribution make OF AMERICA irc and Juliet 40,000 demisE. You don't arseholes at Walnut

I stopped using struts, jsps, etc.... (1)

MartinG (52587) | more than 9 years ago | (#9000933)

.. 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.

Book camparison (1)

rms_nz (196697) | more than 9 years ago | (#9000935)

Anyone read both this one and Struts in Action?

If so how do the two compare - is either one better than the other?

mod u4 (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#9001405)

ffel obligated to is not prone to we all know,

Arrg. Don't link the poor Wikipedia! (-1, Offtopic)

Anonymous Coward | more than 9 years ago | (#9001581)

It feels slashdotted even without being actually slashdotted.

Struts is great but.... (4, Informative)

Decaff (42676) | more than 9 years ago | (#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.

Re:Struts is great but.... (5, Informative)

activewire (515493) | more than 9 years ago | (#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.

Velocity (0)

Anonymous Coward | more than 9 years ago | (#9004924)

Heh. For the project I'm developing now with Struts I already replaced JSP with Velocity. Much more readable, much easier to write. Also I don't need a fancy web-server (read- caucho resin) to run it fast, Tomcat does the job quite well.

And as for other projects, well, i have my own framework that's WAY better than struts (also using Velocity), and I use it whenever I work with a smaller team that isn't afraid to learn something new. I hope to open source it one day, but well, now it is too far from being in the state where I could put it on sourceforge.

--Coder

XWork / WebWork? (2, Interesting)

danharan (714822) | more than 9 years ago | (#9002298)

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?
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Sign up for Slashdot Newsletters
Create a Slashdot Account

Loading...