This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Controller in MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Controller in MVC" Watch "Controller in MVC" New topic
Author

Controller in MVC

Prabodh Reddy
Greenhorn

Joined: Dec 19, 2005
Posts: 14
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

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Oct 07, 2005
Posts: 637
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?


ASCII silly question, Get a silly ANSI.
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
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..


Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Prabodh Reddy
Greenhorn

Joined: Dec 19, 2005
Posts: 14
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
GeeCON Prague 2014
 
subject: Controller in MVC