• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC without use of Struts

 
Vijay jai Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vijay jai Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this article which outlines the various patterns involved, will be helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic