They are similar. MVC is a pardigm by which you can separate an application
into tiers or modules. The Model is usually part of the persistence layer
representing a row in a table. The Controller is usually part of the
front-end that handles getting data from a form, calling upon the logic to
do something with that data, then sending back a View that uses any results
(or anything else) the logic has done with the data that came in. The View
is the page the client sees that represents what the logic has done, or it
could be just as simple as a "Thank you" page upon completion of something.
This is a very general definition. There are many uses for MVC, such as in
Swing components.
Model 2 makes use of the MVC architecture in that you have single servlet,
the Controller, that directs the path of the incoming request to "extension"
controllers (in my framework, Struts, and others they are called Action
classes, but they could very well be servlets that extend a generic
Controller Servlet). Those action classes or servlets are responsible for
calling upon the logic (which in J2EE would be EJB usually), then they would
populate a javabean to maintain the state of the client, then forward to a
JSP page (or use XSLT to transform dynamic XML into HTML) and send that back
to the client.
There are other Models, (1, 1.5) that can be used instead of Model 2, but
Model 2 has been recognized as the most widely used for scalability and
multi-tier programming.
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Sunil Roy
Sent: Sunday, November 05, 2000 5:14 AM
To: [EMAIL PROTECTED]
Subject: Re: [TIP] JSP Model 2 Architecture and DreamWeaver is a pain.
Kindly tell me whether the Model 2 Architecture is the same as the
Model-View-Controller Architecture?
If no, then what is the Model 2 Architecture?
Regards
Sunil Roy
----- Original Message -----
From: "Hans Bergsten" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 09, 2001 12:49 AM
Subject: Re: [TIP] JSP Model 2 Architecture and DreamWeaver is a pain.
> Peter Pilgrim wrote:
> >
> > I have been using JSP in the Model 2 architecture with a special
> > controller servlet. I have been using DreamWeaver V3.0 to
> > design the pages and of course DW 3.0 conveniently writes out
> > a lot of the JavaScript for you.
> >
> > <body onLoad="MM_PreLoad( 'images/dogfood.gif") .... >
> >
> > So I took the raw HTML/JavaScript and insert it into a proper JSP,
> > because DW3.0 does not support JSP (UltraDev does but I haven't got it).
> >
> > I found that the JSPs are wrong are wrong after the controller servlet
> > is invoked. By the first time the controller servlet is invoked
> > ("/servlet/ControllerServlet") then the request URI has changed and
> > the original relative URI "images/dogfood.gif" is been interpreted
> > wrong. The browser thinks it should load "/servlet/images/dogfood.gif"
> > which is nonsense of course. So I had to PAINFULLY do something
> > like this:
> >
> > <body onLoad="MM_PreLoad( '<%= request.getContextPath()
%>/images/dogfood.gif") .... >
> >
> > for all of the MM stuff and every single JavaScript invocation.
> > So I said f**k it. And wrote a custom action tag to help make thing
easier
> > see below
> >
> > <body onLoad="MM_PreLoad( '<app:homePath/>/images/dogfood.gif")
.... >
> >
> > It is a little easier. But it is a f***ing pain, man, cleaning up after
DreamWeaver,
> > because sometimes there are a dozen or more rollover gifs and other
DHTML.
> > but this is not MM fault, but gravy real gravy. I haven't got UltraDev
here I dunno
> > if it fairs any better.
> >
> > If any body got a better solution to this problem I'd be interested hear
of it.
> > This is the __BAD__ side of Model 2 MVC architecture, for real!
> > [...]
>
> I describe a solution to this problem in my book (Chapter 14): create a
URL
> mapping for your controller servlet so that you can use a URL to invoke it
> "at the same" level in the URI structure as your JSP pages.
>
> Say you have a JSP page at the top level of your URI structure ("foo.jsp")
and
> it contains a relative URI to an image, "images/dogfood.gif". As you have
> discovered, if you invoke the controller with
"/servlet/ControllerServlet",
> the browser will interpret the relative image path as relative to
"/servlet",
> and that's not what you want. But if you create a URL mapping for the
servlet
> so you can invoke it with "/myController", the relative path in the JSP
page
> will be interpreted relative to "/" instead, and you get the behavior
you're
> after.
>
> For more about this, read my JavaServer Pages book:
>
> <http://TheJSPBook.com/>
>
> Hans
> --
> Hans Bergsten [EMAIL PROTECTED]
> Gefion Software http://www.gefionsoftware.com
> Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets