Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Design Question - Controllers  RSS feed

 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've finally wrapped my head around the concept of using JSP for the view, a servlet for the controller, and POJOs for the model. I find myself routinely falling back into this pattern for my controller, which I totally fabricated in my head and I have no idea if it is good/bad/otherwise.

I basically define an enum in my servlet class called Action that contains values I expect to receive as a parameter. I attempt to match the request parameter stored in "action" to one of the enums. Then I enter a switch statement that switches on the enum values. Each case does whatever it needs to to the model and sets the url string for the dispatcher. At the end of the switch statement, I forward the request using the dispatcher.

Is this how a controller should work? Are there any good resources available on controller design/patterns/etc?
 
Siddharth Naik
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite sure about patterns for controller but frameworks might help! I like struts (http://struts.apache.org) framework where all heavy duty controller work is already done. Then there are also other popular frameworks like Spring (http://www.springframework.org)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are just looking for a simple implementation of a Front Controller, you might want to check out my FrontMan project (link below in my sig).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!