Choosing the right pattern.

Hi,

I've a servlet that will handle page redirection and page flow. I've read about various design pattern and was hoping that I could implement some of them onto my codes.

However, there are various patterns that seems to be applicable and was wondering which is a better option. 2 patterns in particular was rather applicable; State Pattern and Command Pattern. Both are behavior patterns.

My scenario is like this:

My servlet will recieved a paramater that decide what it should be done. Based on this action, it may be "loadPageA", "submitPageA", "loadPageB"..etc.

So based on the action, my servlet will do some processing. Eg, if action is loadPageA, my servlet will retrieve information that need to be displayed and redirect to pageA, if action is submit, it will receive parameters from the request object and save them.

Both design patterns I've mention are useful when this kind of switch case scenario happens, however, which would be a better option?

Any opinions are welcome, thank you.

-chiew boon

[1071 byte] By [Chiew_Boona] at [2007-11-27 0:04:35]
# 1
http://java.sun.com/blueprints/corej2eepatterns/Patterns/FrontController.html
GhostRadioTwoa at 2007-7-11 15:59:47 > top of Java-index,Other Topics,Patterns & OO Design...