aspose file tools*
The moose likes JSP and the fly likes MVC - Controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "MVC - Controller" Watch "MVC - Controller" New topic
Author

MVC - Controller

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
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

Joined: Nov 27, 2001
Posts: 1561
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 ]

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Mar 06, 2001
Posts: 13459

1 minute? Damn you Andrew Monkhouse!!! (need a 'shaking your fists at the sky' emoticon)

Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
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

Joined: Mar 06, 2001
Posts: 13459

Stone the crows, how did that happen?
Still, wouldn't you prefer I blamed him?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC - Controller