2 answers | 0 trackers
How does the MVC software architecture work?
My project group has decided on the MVC model cos the lecturer recommended it, but we're not very sure how it works.

Suggested by:
Michelle Wong
February 9, 2011
Answers:


Benjamin Teo (+10)

I used the MVC model during my own CSC207 project, so maybe I can share about how it works.

 

The Model will be in charge of the persistant data. In my case, we had JSP pages serving data from a PostgreSQL database. Our models were in charge of retrieving the relevant data from the database, and passing it on to the View for display.

View is for displaying the data that you have to the user. Typically you will retrieve this data from a model, and format it for display on the screen.

The Controller receives input from the user and directs both the Model and View to do certain actions based on that input. It "controls" how the application behaves, hence the name.

 

A quick example would be a login page for a website. After you enter your username and password and click Login, the Controller detects this action and passes the user input to the model. The Model will check the database to make sure that the username and password match, and if it's correct, it will tell the controller that this user is valid. The controller can now instruct the View to display a message saying "Successful login".


Answer posted on February 9, 2011


Yew Kian Ang (+4)

For JSP, your JSP Page will be your View, Servlet will be your Controller, Beans will be your Model
That should be how you structure in MVC style for JSP 


Answer posted on March 25, 2011

Please login to give an answer.