Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC - Controller

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why in MVC the controller is Servlet ? Why can't we use JSP for control as in turn it becomes servlet.
Is there any other benefit using servlet?
Regards,
aakash
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aakash bhatt:
Why in MVC the controller is Servlet ? Why can't we use JSP for control as in turn it becomes servlet.
Is there any other benefit using servlet?
Regards,
aakash

My $0.02
Since JSP should be used for presentation logic only, it makes more sense to use a servlet as a controller. Servlet process business logic and should be pure java code. But I've also seen cases in which you can use a JSP as a controller. Have a look at
this article, there's a jsp named process.jsp that acts as a controller.
Notice also that it does not have any presentation at all (HTML). It's got pure java code to forward the request to the appropiate destination.
HTH
[ September 16, 2003: Message edited by: Andres Gonzalez ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you design your JSP poorly, it is possible for white space to 'leak' into the output buffer. As long as you remain under the buffer size you'll never know, but this is slightly less efficient.
I have encountered the case where there was so much white space, the buffer was comitted and they were unable to forward. This was an extreme case, but it just won't happen in a Servlet.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 minute? Damn you Andrew Monkhouse!!! (need a 'shaking your fists at the sky' emoticon)

 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
1 minute? Damn you Andrew Monkhouse!!! (need a 'shaking your fists at the sky' emoticon)


Andres Gonzalez
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stone the crows, how did that happen?
Still, wouldn't you prefer I blamed him?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic