Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Would struts be appropriate?

 
Pat Wallwork
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have 3 rather small Java sites I maintain and occasionally take on other small projects. My impressions about struts so far is that you benefit from it mostly on larger sites where multiple programmers are working on it.
As I handle all aspects of these sites from design to backend programming and already utilize my own version of an MVC pattern would I still benefit from incorporating struts into my existing sites or possibly future ones?
Thanks for any advice,
-Pat
 
Doug Wang
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pat,
I think it depends on how different your version of MVC pattern is compared with the pattern Struts implements?
 
Pat Wallwork
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest I haven't looked at struts at all...I just keep hearing about it often. Because of this, I'm not sure if what I'm doing already resembles a basic struts idea or not.
Basically my main goal is to keep as much code out of the jsp pages as possible. I use Servlets to handle requests from my jsps (usually form values) and the Servlets usually do a little processing like validations, login check etc. If everything is good then at this point my servlet usually calls in a class that specifically handles the main part of whatever needs to be done.
That kind of sums it up and so far it works pretty good for me. Keeping in mind that my sites are never really anymore than 100 pages or so, that I do all the layout, HTML, design, programming, etc. myself, and the fact that it will probably stay this way as I have no intentions of moving on to bigger projects...would struts still be a wise thing to learn and utilize?
Thanks again,
-Pat
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have multiple servlets (one per JSP page), your architecture might not be very close to Struts. You may even find that the seperation between your model (bean) and controller (servlet) starts to get blurred.
Struts provides its own controller servlet, and most of what you have in your different servlets will probably be moved to Struts Actions. If you need to do things in the servlet init() and destroy() methods, you will use a Struts Plugin.
However, there are probably a lot of reasons why you might want to consider converting to Struts. As a framework, it is probably more robust, because it has been used in a wide variety of applications, and because the source code has been pored over and refined by many very smart people. And it's a commonly known framework, so other developers who might need to look at your site will have a smaller learning curve (assuming they know Struts).
Even without the framework, there is a good set of JSP TagLibs. I'm pretty sure you can use the TagLibs without using Struts. (Someone jump on this if I am rong).
Also, there is a lot of third party support for Struts. It is built in to Websphere 5.0, and there is a plug-in for Struts projects in Eclipse.
Finally, you might want to take a look at Sun J2EE Design Patterns: Front Controller which describes the reasons to use a single servlet (called a Front Controller pattern).
 
Pat Wallwork
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
I appreciate your response. I do use several servlets in my sites so it sounds like struts may help simplify my own MVC pattern. Curiosity is getting the best of me and I think I'll go to Chapters and buy myself an early Christmas gift on struts now :-)
Thanks again,
-Pat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic