Thursday, May 3, 2012

Understanding the MVC Architecture

MVC architecture briefly means Model View and Controller architecture.


Model consists of complete business logic of the system.
For example, storing data passed by user in an object, connection and calls to database, storing & retrieving data from database, processing data, performing necessary calculations, preparing results etc.

View is mainly responsible for User Interface part of the system.
For example, creating forms to get data from user, creating forms which displays result to user etc.

Controller provides bridge between Model and View. It controls the whole system flow. When user passes the data to process, controller gets the data from that View and passes to necessary Model for further processing.

figure:1
Once Model is finished processing and calculating operations, it sends the result back to Controller and it again call some View to display result.

In this project, the system is divided in MVC Architecture like this:


Model: JSP Bean class and its functions (Student.java, ClassRoom.java, StudentSearchService.java, MyValidate.java)

View: HTML and JSP pages (index.jsp, success.jsp, failure.jsp)

Controller: Servlet class (MyServlet.java)





















Students can be searched by the following parameters Student Name, Grade. User can enter these values and click "Search" button.

I have used ArrayList to store and search the student details. Even though I have tried  to use Hash Map for this purpose but I couldn't finished. then I have tried another way.










If the particular student is registered then system will give that student details. If not system will show the error response. If not system will show the error response.

When you input the wrong details the following error message will be shown.




When you click the search button without student name, Error response will be shown.


If you want to download source code click the following link.

https://github.com/smayoorans/yschool-mini-mayooran

Thanks

No comments:

Post a Comment