• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design Patterns in Struts

 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I am new in Struts.

I have just started reading Struts and i am wondering in MVC is the only pattern we can apply if we are using Struts Framework?
 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, thats the whole point of having such a framework isn't it?
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, all you have to do is go to the struts home page and read a few lines and you'll see that's the point of it. What were you looking to use struts for?
 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

MVC isn't the only pattern Struts uses. If you for example uses Struts 2 it uses the FrontController pattern wich is a helper pattern for MVC.

It uses Service To Worker pattern internally, Intercepting filter pattern and some more I guess.

When using tiles with Struts you are in fact using the Composite View pattern. When you build your model you probably will be using the Session Facade pattern, Data Access Object pattern and some more.

Read about them at Sun
[ June 07, 2007: Message edited by: Mathias Nilsson ]
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your comments!!

I remember in one interview i was asked what is a difference between Front Controller and MVC pattern. I never thought about it and I answered that Front Controller has only one controller which takes user input/requests whereas in MVC you can have several controller (thought this is not recommended). Is that correct?

I am new to Struts as i said, and i am reading programming in jakarta Struts and finding it ok but not sure if that book was designed for newbies considering.

Please let me know which book to read (i am use to head first series where lot of things are explained using daigrams...) so that concepts of Struts are clear.

Thanks!
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that the Front Controller helps you not to write scriplet code in the JSP view. A Front Controller typically uses an Application Controller, which is responsible for action and view management.

The front controller is in struts 2 a Filter that functions as a Dispatcher for the action and views. The acion collects data and the Dispatcher forwards to the view. To preserve the Service To Worker pattern we don't want the action to be aware of the view. The dispatcher let's the action know to collect data and then forwards to JSP or other views.

If you find a good book on Struts 2 then please let me know. I'm looking for one
 
Nick Williamson
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried going through struts on the struts website and wiki and it was a pain!!! It's so scatter-brain, I thought it was pretty bad. Anyway I did find this link through it all and this download is pretty well written and goes through the basics of Struts 2 and how to get things done, once you go through this you'll have a good foundation for the new framework.

http://www.infoq.com/minibooks/starting-struts2

You do have to signup on this site, but once you, you can download it. I thought it was a lot better than the struts 2 website. Let me know what you think of it.

Oh and I got this link from the struts 2 website:
http://struts.apache.org/ under recent threads: it's the link called: "Starting with Struts2" Book
 
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From my opinion Struts 1.x also using Front Controller, since it is only using 1 servlet (ActionServlet) as controller. Then the controller will dispatch all the incoming requests to the apropriate Action class. You can read about Front Controller pattern here java.sun.com/blueprints/corej2eepatterns/Patterns/FrontController.html
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Correct. Thats what i exactly wanted to say.

Thanks for the link.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good to know this. I was unaware of this!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic