no. of Servlets
New to MVC.
When we have an MVC model there may be so many JSP pages in the application and number of Java classes to do the business logic and store data. The servlet act as the controller. In a practical scenario will there be only one servlet which act as the controller?.i.e. all the JSP pages calls this controller and it redirects based on the request. Or will there be more than controller servlet.?
Please clarify.
thx
[459 byte] By [
ujastian] at [2007-9-30 12:28:17]

> In a practical scenario will there
> be only one servlet which act as the controller?.i.e.
> all the JSP pages calls this controller and it
> redirects based on the request.
Ideally yes. There will be one controller servlet with all jsps submitting to the controller. For processing of requests the controller may invoke some class(called handlers, one for related use cases).
>Is this
> handlers(Java classes) act as a controller again?>
No. But it does work with request and response objects. The servlet instantiates the appropriate handler and calls a handler method and passes the request and response objects. In the handler method you can take appropriate action for request processing and forwarding to the appropriate jsps. Implementation of how the servlet instantiates the right handler is left to you(reflection is one solution).
>Is
> no. of handlers depends on no. of types of request?
Yes. As I said before, keep one handler class for related use cases.
However, if you want a cleaner solution and have enough time , go for a framework
> >Is
> > no. of handlers depends on no. of types of request?
> Yes. As I said before, keep one handler class for
> related use cases.
>
> However, if you want a cleaner solution and have
> enough time , go for a framework
He has a framework, just not one of the big ones like Struts (which IMO is not a good choice for most people).