• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

am I using MVC correctly?

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to determine if I am using the model-view-controller (MVC) pattern correctly. I have a web application which uses JSPs and JavaBeans (no EJBs). The user must login to the application. After doing so, 99% of the user's activity is read-only. That is, the user selects an item to view greater detail on and can see various levels of detail. The only user entry is for a few profile settings. I am not using servlets because I didn't want the address bar in the browser to display the long path and not be updated to the appropriate jsp page name. The only places that servlets should probably be used are when the user logs in and changes his profile settings.
All of my database connectivity is done in a single java bean class in my package. Each method of this java bean class (Service.java) accesses a different stored procedure in Sybase. The data from the stored procedure is returned to the calling JSP in a Vector, String, or another java bean. The JSP displays the data and relies on styles in a linked CSS file for the presentation. Some JSPs use tag libraries to help with the display. I am in the process of using the tag libraries through more places in the JSPs.
I would like to know if this is an acceptable manner of using MVC. My company is in the early stages of migrating to WebSphere Portal Server (WPS) and I've been told that WPS relies heavily on Struts. While investigating Struts, I've found that Struts relies heavily on MVC. I've been doing some reading on MVC but haven't found any concrete examples of how to implement MVC. Most of the articles just define what the MVC elements are.
Any hints at MVC and Struts are greatly appreciated. Thanks in advance.
By the way, I put this in the JSP forum because I couldn't find a portal forum.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than looking for articles on MVC, do search for the term "Model 2". This is the term usually applied to the pattern used as an MVC approximation for web applications.
hth,
bear
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From your write up, it seems to me you are using model 1 architecture where you delegate functionalities of you application to a bean. To use MVC model 2 which is widely advocated you have to have a controller which in most cases should be a servlet; hence there is the view just for the display and collection of data to and from the user, the model which is your bean and the controller which is your servlet(servlet controller) One book that addressed both models in details is Advanced Java Server Pages - David M. Geary.
I hope this helps.
Anselm Paulinus.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So for my own clarification:
If you have a JSP page where a JavaBean is encapsulating the logic and the data this is Model 1 architecture.
If you have a JSP page where the JavaBean is supplied from a controller class (servlet, EJB, etc) this is Model 2 architecture.
Is that right?
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The controller class is the class that takes control i.e. issues commands to the rest of the applications; it issues command to your EJB to open and get data from you database issues command or stores the data in a helper class or bean and issues command to the view i.e. JSP to display the data - reason why it is called control Servlet the session bean and entity bean of your EJB are not the controllers; you might have to Look for the text core J2EE patterns as well as other books on patterns to help with your designs. It is nice to start knowing this different patterns early in ones career as it helps in knowing why you are adopting a particular strategy over another.
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic