File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts - MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts - MVC " Watch "Struts - MVC " New topic

Struts - MVC

Senthil Panneer Selvam Kumar

Joined: Mar 28, 2003
Posts: 2
I am new to struts. Please clarify the struts framework from the MVC architecture point of view.
Core application modules/Data Storage - Model
Action classes/Event handlers -- Controller
JSP forms/pages – View
How about the XML description files?
Sue Spielman
Ranch Hand

Joined: Apr 21, 2003
Posts: 56
The XML decriptor files are used by the controller so that it knows what it should do with each incoming request. The controller also uses the information providing in the action-mappings to determine what instance of the action class needs to be instantiated, what form is associated with the action (and instantiate that class if need be), as well as what to do in terms of forwarding. The action mappings define the wiring of your application because each ActionForward that is returned from an action, has to be defined in the struts-config.xml somewhere. Whether it is a global-forward of action specific forward.
Check out chapters 2 & 6 for specifics on how to do various configuration tasks.

President/Consulting Engineer<br />Switchback Software LLC<br /><a href="" target="_blank" rel="nofollow"></a>
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
What are the benifits of using Struts as MVC pattern when compared to JSP(V) - Servlet(C) - Java Class(M) concept.


SCJP 1.5, SCEA, ICED (287,484,486)
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
Those of you on the struts-users list can skip the following--Copy&Paste rules.
1) How about this one from my RL experience...
I filled out a eBiz order form and mis-keyed my CC exp date. My transaction was rejected, and I was returned to the form... with nothing in it! I had to re-key everything. The Struts HTML tags take care of this problem for you, rather than having to trust that the browser will cache it or the user won't mind re-keying everything. HINT: If a user has to re-key something, they probably won't, resulting in lost business.
2) The key is that Struts helps you control the flow. You can skeleton out a whole app before it's even possible to write the business logic. I speak from experience here--I had a whole app laid out and assembled 6 months before the DBA's finished the schema for my data mart. I dropped in the logic, and voila, everything worked. Struts is *not* a business logic framework. It *is* a VC framework, waiting for your M. =) Trust me when I say once you learn it, it will save you time.
3) The key here is that Struts does everything for you that you'd have to write yourself.
If you want to write it yourself, feel free. Meanwhile, I've got a set of wheels and I'm off building apps. =)

"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The team, Newsletter 039.
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 129
So, does that mean that struts are about patterns and we are likely to see an array of standard patterns emerge in the Enterprise world?

Darryl Failla
Sun Certified Java 2 Programmer
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Hi there,
Patterns, eh? Here is an interesting read...
In pp. 577-578 of Manning's book on Struts, the author provides a list of well-known design patterns and states how they are implemented in Struts. The list is as follows:
Pattern: Service to Worker
Struts Component: ActionServlet, Action
Pattern: Command, Controller, Front Controller, Singleton, Service Locator
Struts Component: ActionServlet, Action
Pattern: Dispatcher, Navigator
Struts Component: ActionMapping, ActionServlet, Action, ActionForward
Pattern: View Helper, Session Facade, Singleton
Struts Component: Action
Pattern: Value Object, Value Object Assembler
Struts Component: ActionForm, ActionErrors, ActionMessages
Pattern: View Helper
Struts Component: ActionForm, ContextHelper, tag extensions
Pattern: Composite View, Value Object Assembler
Struts Component: Template taglib, Tiles taglib
Pattern: Synchronizer Token
Struts Component: Action
Pattern: Decorator
Struts Component: ActionMapping
Very interesting!
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148

What are the benifits of using Struts as MVC pattern when compared to JSP(V) - Servlet(C) - Java Class(M) concept.

Struts is a web application framework that encourages MVC application arcitecture. The framework is used to build web applications based on the MVC architurural pattern. It comes along with other useful things that would be nightmare for any developer (or team of developers) to implement and maintain like validation, request control, view layout. Struts include those extra stuff as part of its framework.
Why re-invent the wheel again?
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303

Because framework manufacturing is a bit of a cottage industry :-)
jQuery in Action, 3rd edition
subject: Struts - MVC
It's not a secret anymore!