• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MVC - model 2

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
does anyone wants to explain the MVC pattern and how it is related to servlets and JSPs and Java Beans. If you can provide the simplest example I would truly appreciate it.
Thanks
Vladan
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll give it a shot. Basically, the model-view-controller pattern separates a model from its views (and, optionally, controllers to change the model). A simple example could be some kind of data (e.g. financial data), and several vies showing this data, e.g. as a chart, a graph, etc. You might also be able to modify the data in the chart, so this would also act as a controller.
In a JSP-based web application, MVC could be implemented this way: A JavaBean would contain the model, consisting of some data and business logic (e.g. a stock portfolio). One ore more JSP pages can use the JavaBean to display this model, or aspects of the model. They would also (possibly) act as controllers to modify the data in the model, e.g. by allowing the user to add a new stock to the portfolio.
I hope this makes sense. :-)
-Mirko
 
Vladan Radovanovic
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actaully I am familiar with MVC and I just want a simple example how it is related to Servlets, JSPs and JavaBeans.
Thanks
Vladan
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The usual association of MVC to servlets, JSP and beans is:
JSP = View
Servlet = Controller
Beans = Model
In this approach, JSPs should contain mostly formatting, with (if necessary) a small amount of data access from the Model (beans) to show the data in an appropriate format. The Beans should be a complete data model, but contain no View or Controller code (so no "getAsHTML" type methods). The Controller part of MVC is always the hardest to pin down, but in this approach one or more servlets looks after workflow and program state, managing what information is stored in the context or session, which JSPs are displayed and what changes are made to the beans data model.
Has that helped?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai all
You can find an excellent example at the following link:
http://www.javaworld.com/javaworld/jw-03-2000/jw-0331-ssj-forms.html
Praveen
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic