Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC

 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use it as your controller.
Ideally, your model classes should be able to function outside of a servlet container.
 
michel dughlas
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic