aspose file tools*
The moose likes Servlets and the fly likes MVC without use of Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "MVC without use of Struts" Watch "MVC without use of Struts" New topic
Author

MVC without use of Struts

Vijay jai Singh
Greenhorn

Joined: Jan 07, 2009
Posts: 26
Hi all,

I am trying to develop a sample project which is based on MVC. I want to implement MVC without use of Struts.

Could you please help me regarding designing of application. I want to know how should i implement it

1) should i create a Controller Servlet and after submit on every jsp i should redirect to that Controller Servlet and based on request coming from JSP i should redirect to corresponding Servlet.

or 2) every servlet should work as controller and directly from JSP i should redirect to corresponding servlet.

or 3) any other approach i should follow.....

Thanks and regards
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
You can have One Servlet acting as Controller.
All your requests can point to this one servlet.
Based on something in the request, like a param value, url etc, you can invoke your business logic in a java class, and once done forward to a JSP page.

You can have a configuration file which stores information about what java class to invoke for a particular url/param-value, and which jsp to forward to. (which would be similar to struts-config file)
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688

James Ward wrote:You can have One Servlet acting as Controller.
All your requests can point to this one servlet.
Based on something in the request, like a param value, url etc, you can invoke your business logic in a java class, and once done forward to a JSP page.

You can have a configuration file which stores information about what java class to invoke for a particular url/param-value, and which jsp to forward to. (which would be similar to struts-config file)


Yes, James told you make one servlet which is work as Controller. Or you can divide your Servlet controller according to your module wise. Make different servlet according to application module.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Vijay jai Singh
Greenhorn

Joined: Jan 07, 2009
Posts: 26
Nishan Patel wrote:

Yes, James told you make one servlet which is work as Controller. Or you can divide your Servlet controller according to your module wise. Make different servlet according to application module.


Nishan as you are saying i can divide Servlet controller according to module wise. But generally it is preferred to have one controller in application. Correct me if i am wrong.

Thanks
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688

Yes, you are right, but what if your application is big and contains many module then it is hard to handle complexity with module. your module conflict with same controller servlet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

Perhaps this article which outlines the various patterns involved, will be helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC without use of Struts