Design Pattern Question


General J2EE: Design Pattern Question

  1. Design Pattern Question (5 messages)


    The current architecture of my application is:

    JSP View1 ----> Servlet1 -----> JSP View2
    JSP View2 ----> Servlet2 -----> JSP View3
    JSP View7 ----> Servlet5 -----> JSP View4

    In other words, all the views that have Forms have their own controllers (servlets). The task of all the Servlets is to do validation and decide on the next view to display.

    * Is this a good approach?
    * Or should I use the Front Controller pattern, have a single Servlet as the Controller and turn each of the existing Servlet Controllers to regular Java class controllers?

    Any input is highly appreciated.

    Threaded Messages (5)

  2. Design Pattern Question[ Go to top ]

    I personally feel that using the FrontController Architecture is more easy to maintain. -PG
  3. Design Pattern Question[ Go to top ]

    PG is right on.
  4. Design Pattern Question[ Go to top ]

    Yep one controller seems to easier to maintain, single point entry makes security, exception handling, logging, easier.
  5. Design Pattern Question[ Go to top ]

    As other people have pointerd out, front controller is the standard way of approaching this problem. With current technology it is the simplest approach w.r.t. security, flow control etc.

    The thing I don't like so much about the front controller, however, is that it makes decoupling parts of an application difficult. Ideally, I would like to be able to 'componentise' an application - not just the business logic, but the user interface too. I could then package and deploy parts (features) of the application separately just by changing a few configuration/deployment descriptors.

    Unfortunately, I have found this difficult to achieve in practice because splitting parts of a web application into different wars means that they can't share the same context - creating problems with authentication and state control etc.

    Any thouths on this appreciated!

  6. Design Pattern Question[ Go to top ]

    I sure appreciate your answers.
    * I've decided to make a slight modification to the architecture.
    * I've introduced a "Main Controller Servlet" that acts as the single point of contact. It reads a config file and forwards the request to the appropriate Controller servlet.
    * This is the architecture I have now.

    JSP View1 ---> Main Controller ---> Servlet1 ---> Some JSP ViewA
    JSP View2 ---> Main Controller ---> Servlet2 ---> Some JSP ViewB
    JSP View3 ---> Main Controller ---> Servlet1 ---> Some JSP ViewC

    Appreciate your comments/thoughts on this. Thanks.