Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

MVC without use of Struts  RSS feed

 
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
 
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)
 
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.
 
Author and ninkuma
Marshal
Posts: 66799
168
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!