• 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

Problem deploying MVC with Tomcat

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody. I am doing a project that requires me to implement a simple Model-View-Controller on my web server that uses Tomcat 5.5. The files that I am using are the ControllerServlet class, PersonBean class, and two jsp files hello.jsp and goodbye.jsp. The MVC we are supposed to implement is the one on this webpage:http://www.informit.com/guides/content.aspx?g=java&seqNum=117
I have already compiled my classes but now do not know where to upload all of these files on my web server. The two class files are in the package com.informit.webtechnologies. I have tried contacting my professor and fellow classmates and nobody has gotten their MVC to work yet. I am completely new to this and am taking my first web design class, which at our school gives us a week to learn each language. I would appreciate anyone who can simplify this process for me. Thanks
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like any basic web applications, these classes should be kept under your WEB-INF/classes folder. If you package them in a JAR file, you can put the JAR file under WEB-INF/lib.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to be pedantic, I'm going to point out that "true" MVC is impossible on any web-based system. That's because one of the things an actual MVC system has to have is the ability for the controller to post updates to the View when the Model changes. HTTP is strictly a Request/Response protocol and has no ability to asynchronously notify the client (browser) if the Model is changed between requests. The best that can be done is to include those changes with the next Response. This failing can be reduced by using AJAX to poll for changes, but it's still not going to result in a 100% pure MVC. There will always be quantum discontinuities.

However, in the real world, we're happy with "close enough". Several attempts were made over the last decade or so to get as much of the benefit of MVC as possible. One of the more successful ones was the development of the JavaServer Faces framework. Although it can't do anything about HTTP's limitations, and there is a small amount of co-mingling of code between Model and Controller, JSF has indeed proven "close enough".


 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm surprised that your professor jumped straight to MVC before having the class write some simple hello world apps to get people familiar with the file structure of a Java web application. You might want to look around for some web tutorials or books on servlet programming to make sure you get all the fundamentals down before moving on to things like this.

We have some tutorials in our Cattle Drive. There is a servlet section there and it covers MVC.

We also have some example applications in our CodeBarn. The servlet applications are packaged as war files so they can be download and dropped into your tomcat/webapps directory. Once in there Tomcat will automatically unpack them and deploy them. There is an MVC app there as well.
If you download and deploy that, you'll have a running copy of an MVC app (with code) that you can use to compare with the one from the link you posted.

See: http://faq.javaranch.com/java/CodeBarnServlets
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Tim Holloway

Good comment. Thanks
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That's because one of the things an actual MVC system has to have is the ability for the controller to post updates to the View when the Model changes.



This ability is an implementation detail for a specific type of MVC implementation. The MVC OO design pattern itself does not prescribe any such requirement.

MVC-based applications which are implemented with a HTTP-based View are also "true" MVC implementations. They are just a different type of implementation than the one you describe.

A particular object-oriented design pattern can have multiple implementation styles.
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Pinkerton wrote:

That's because one of the things an actual MVC system has to have is the ability for the controller to post updates to the View when the Model changes.



This ability is an implementation detail for a specific type of MVC implementation. The MVC OO design pattern itself does not prescribe any such requirement.

MVC-based applications which are implemented with a HTTP-based View are also "true" MVC implementations. They are just a different type of implementation than the one you describe.

A particular object-oriented design pattern can have multiple implementation styles.



I'm showing my age. I can remember when it was still acceptable to call it Model/View/Editor. Microsoft describes 2 variants of MVC, active and passive. http://msdn.microsoft.com/en-us/library/ms978748.aspx

Active MVC relies on a 2-way asynchonous message flow. Passive MVC relies on the Observer Pattern, which, as they mentioned, is the best you can do using HTTP as a transport mechanism.

MVC was not considered as a formal "Design Pattern" in the seminal GoF book, but rather as an assembly of alternative Design Patterns. They declined to define a term for such assemblies, however. Missed opportunity.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be cool to stop hijacking the thread and to know if Gabriele has solved his/her problem
reply
    Bookmark Topic Watch Topic
  • New Topic