Web tier: servlets, JSP, Web frameworks: Can anyone Suggest a General Design Pattern for the Approach

  1. Problem statement : There are ServletRequest & Response Objects , validate the Request Object for parameter values
    and depending on one of the parameter value update a Record like structure and log the data.And redirect the page depending on the value returned after logging.

    Threaded Messages (4)

  2. Interceptors[ Go to top ]

    Sounds like Interceptors can be used for that. If this can take place after more then one form request then Interceptors are great for this. WebWork2 has interceptors right out of the box and Struts has it too but it is an add on. The validate can be its own interceptor then you can have a seperate interceptor for updating the record and redirecting.
  3. Interceptors[ Go to top ]

    Thanks for a quick response. Some info on the Interceptor Pattern
    Still analysing how exactly does it fit into
  4. Interceptors[ Go to top ]

    check this out
  5. See, you used the word "and" several times. So the most natural way is to use Chain of Responsibility design pattern described by GoF.

    Next, you say "...and depending on one of the parameter value update a Record...", so you need a parameterized Singleton (or more precisely factory that returns singletons). BTW, validation of parameters will require similar approach unless you are executing just domain (type) validation.

    As far as you are talking about web tier, ServletFilters is a first candidate to evaluate, IMHO.