• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Best practice controller implementation for different actions

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose I have actions like edit delete and update. If so what is the best practice to implement the controllers. Is it like one servlet map to different actions or separate servlets for each action?

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One servlet is much more common. That's how most web frameworks work as well. One servlet to delegate to the proper class that does the work. You want to avoid having non controller login in that servlet though. Your logic should be in other classes you delegate to. And there would be one of those per action.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote: Your logic should be in other classes you delegate to. And there would be one of those per action.



Those are the model classed in MVC architecture know.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harshana Dias wrote:

Jeanne Boyarsky wrote: Your logic should be in other classes you delegate to. And there would be one of those per action.



Those are the model classed in MVC architecture know.



No, that's not what's she's talking about. Perhaps this article can help.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is fine to have one controller for both delete and update action as long as they can be functionally grouped. Even frameworks like Struts and Spring MVC had DispatchAction and MultiActionController for the same usecase.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Piyush Mangal wrote:It is fine to have one controller for both delete and update action as long as they can be functionally grouped. Even frameworks like Struts and Spring MVC had DispatchAction and MultiActionController for the same usecase.


That's true. The original poster didn't sound that far down in design so I answered differently.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic