Difference between MVC1 and MVC2

First of all there is no MVC1 pattern.  Surprised?

Initially, the server side web development was achieved using Servlet in the space of JAVA technology.  But developing web page response using Servlet technology was tedious and error-prone.  In Servlet, we use to write all presentation logic in out.print, as response.  So it was very difficult for web designers to maintain or alter the persentation logic code, written in Servlet. 

To overcome this issue, JSP technology arised.  With JSP, the web designer need not have JAVA knowledge.  It is very easy to maintain code in JSP.  Thanks to Scriplets and Custom tags.  We can have JAVA code, if needed to retrieve data, within scriptlet.   But there is also drawback in JSP programming. Developers use to have all code logic in one scriptlet in JSP.  All code logic means database code, HTML (presentation) code and business logic or any Javascript validation logics.  Developers use to retrieve data from database with the help of bean class directly from JSP and render it the same.  This leads to lack of code reusability.  There is no separation between presentation and business logic.   This concept has been called as “Model 1 JSP programming”.  Not MVC1.  Got it?

In order to achieve the separation, Trygve Reenskaug invented MVC pattern.  MVC pattern refers to separation of Model, View and Controller.   With this pattern, developers have to write Bean or POJO classes (Plain old JAVA class) in Model layer, with SERVLET as Controller which forwards the response to JSP technology to present to the users, View layer.

So there is a clear separation of business, mapping or contol and presentation logic. 

– User request goes to Contoller component (SERVLET).

– Controller (SERVLET) fetch required Models (POJO class) to accomplish business requirements.

– Controller (SERVLET) frames the response and forward the response to View component (JSP).

– View component (JSP), formats and renders the response to present it to the user.

 

This kind of programming has been called as “Model 2 JSP programming”.   Sometimes called as “MVC2”.  This leads to confusion in the name that there exist MVC1.

But the fact is, there is no MVC1 or MVC2, only the MVC.

cool!!

Advertisements

2 Comments

  1. Subbu.
    Posted February 19, 2013 at 12:02 pm | Permalink | Reply

    Sounds good….

    • SARAVANAN SIVAJI
      Posted February 23, 2013 at 1:04 pm | Permalink | Reply

      Thanks for your comments!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: