• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to avoid if-else blocking in controller servlet  RSS feed

 
Vrushali Gore
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i make use of MVC pattern for my J2EE application development, then i have to write if-else blocking in Controller Servlet. How we can avoid writting this? Is there any pattern available to avoid this?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try Struts-like. Define some action mappings in a file, and register each of them in a Map.
<action path="/Hello" forward="/pages/Hello.jsp"/>

When your controller gets for example "/Hello.do", it strips ".do", and looks for the corresponding action "/Hello" in its action map.
If-else are then history
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vrushali,

Though i dont get your context fully, i think you are looking for a central place where you can take the decisions to forward/direct the control further.

You can use FrontController Pattern thats specifically meant for this task.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this article might be helpful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!