File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes which class is said to be model which class is said to be controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "which class is said to be model which class is said to be controller" Watch "which class is said to be model which class is said to be controller" New topic
Author

which class is said to be model which class is said to be controller

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hi, i am new to struts frame work
here i have little bit of confusion that whether the struts-config.xml file calls controller or model

as far as i know is the a class whcih extends Action (class) is told to be controller

so controller must be called first and then it must call model (which has got setters and getters)

but unfortunatley it is not correct
because i have seen it in the console window by placing some debug statements(SOP) in model class and started the application by sending a request from a jsp page which contains some text fields and a submit button


so here when i press a submit button it internally calls model and then it calls the controller class (the class which extends Action)

But according to struts framework specification the flow is like this..
after submitting the request it checks the path in struts-config.cml file and the it forwards the request to controller and then it forwards to model(bussiness logic) and then returns back to jsp page.

please please ... can any one explain me what happens internally ?



thanks in advance


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Originally posted by saikrishna cinux:

so controller must be called first and then it must call model (which has got setters and getters)
but unfortunatley it is not correct


Hi saikrishna,
the model class is not the one which has getXXX() or setXXX(). It the one which contains the business logic of the application. In the Action class we pass the form in the execute method.
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
thus what you are referring to as model is the Form(which extends ActionForm /ValidatorForm). It is called internally.
Hope it clears your doubt.
Regards
Roshani


Regards,<br />Roshani
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
thanks gopal now i got the concept
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
There are different views on this, but my take is this...Struts does not provide any features that fulfill the Model role. The Model is your database, your business objects, or what ever you use to implement your middle tier. I would place ActionForm classes into the View portion. They are just there to support your JSP and to pass data back and forth between the JSP and Action.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which class is said to be model which class is said to be controller
 
Similar Threads
[URGENT]Problems with Struts and Tiles
Difference between servlet and struts
about struts
Doubts ...understanding the struts architecture :(
please help me to solve following spring issues