This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "MVC" Watch "MVC" New topic
Author

MVC

Pranav Pal
Ranch Hand

Joined: Nov 04, 2007
Posts: 74
Hello everybody
I learnt about MVC from HeadFirst Servlets & JSP
I have a question regarding use of servlets in MVC
Can I use the servlet as both the Controller and the Model or I should use it as the Controller only?
Thanks in advance


Hakuna Matata!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Use it as your controller.
Ideally, your model classes should be able to function outside of a servlet container.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
michel dughlas
Greenhorn

Joined: Oct 31, 2007
Posts: 6
According to MVC architecture Servlet is used for Controller. there is no issue servlet is used for model.

So it is better to use servlets as controller.
Pranav Pal
Ranch Hand

Joined: Nov 04, 2007
Posts: 74
Originally posted by Ben Souther:
Use it as your controller.
Ideally, your model classes should be able to function outside of a servlet container.
Pranav Pal
Ranch Hand

Joined: Nov 04, 2007
Posts: 74
Originally posted by Ben Souther:
Use it as your controller.
Ideally, your model classes should be able to function outside of a servlet container.


Thank you
wang jiajian
Greenhorn

Joined: Sep 20, 2007
Posts: 9
MVC MODEL1 jsp+javabean

use the jsp as both the Controller and the view.

model2 jsp+servlet+javabean

use jsp as the view only

use servletas the Controller only
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1357
    
  17
There is an article that I found very helpful in the FAQ section:
http://faq.javaranch.com/java/Model1Model2MVC

(sorry, I can't remember who wrote it - I just remember the discussion that led to its creation)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MVC
 
Similar Threads
MVC implementation (JSP or Class)
Is there any performance improvement in MVC2 when compared with MVC1 ?
some java interview Questions
Struts Survival Guide
MVC without struts