Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Controller in MVC

 
Prabodh Reddy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in most cases we will be using servlet as the controller.
why can't we use JSP as the Controller what are the disadvantages of using JSP as controller?
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prabodh Reddy:
in most cases we will be using servlet as the controller.
why can't we use JSP as the Controller what are the disadvantages of using JSP as controller?


JSP is not being made for the purpose of writing java code in it. It is for presentation. Other than complexity, maintainence is also the major problem, I can think of...

May be someone else can put more light on this...

 
Stuart Ash
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rathi ji:


JSP is not being made for the purpose of writing java code in it. It is for presentation. Other than complexity, maintainence is also the major problem, I can think of...

May be someone else can put more light on this...



That's a lot of light already

It will help to understand the historical growth of server-side Java programming - the times when they introduced servlets, what motivated them to come up with JSP, and the realization of the need for a more MVCish arrangement, and so on. Someone elaborate this?
 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My typical request from a browser will first go to a servlet which if nothing else will check the users session is still valid and not timed out before using the requestdispatcher to call up whatever jsp is required.

I suppose I could have a filter to check the session of each request but this is just the way I've got used to working in.. So if each servlet has anything else to check its easy to put the code in without having an ever growing filter..
 
Prabodh Reddy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in old MVC we have JSP as the controller why have they replaced it to servlet as the controller what ever we do in servlet we can do everything in JSP.may be for performance issue they will be takindg servlet as the contorller because JSP is converted into servlet..(it takes some time for this conversion)...
if any one knows give more reasons why servlets are used as controllers.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been asked several time so search this and the JSP forum and you will find plenty of detailed explanations.

In short, you can, if you want to.
You can also pound in nails with the back of a wrench.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic