File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 1344
    
  12
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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC
 
Similar Threads
Struts Survival Guide
MVC implementation (JSP or Class)
MVC without struts
Is there any performance improvement in MVC2 when compared with MVC1 ?
some java interview Questions