New Design Pattern:TAGLIB ONLY.No servlets!!

Discussions

Web tier: servlets, JSP, Web frameworks: New Design Pattern:TAGLIB ONLY.No servlets!!

  1. We followed the following architecture:

                        request response
                          | *
                          | *
                          * *
                     ------------------------
                       servlet JSP
                     ------------------------
                             ejb
                     ------------------------

    1.Request is given to servlet.
    2.servlet fetches data from the Ejb layer
    3.servlet forwards data to jsp
    4.jsp genreates view to the user


    Now we find the following Main TROUBLE with this architecture

    The jsp can present only those data that has been provided by the Servlet,i.e. jsp can not demand various differnt types of data from the business layer as it needs.
    Reason is Servlet forwards the JSP.

    solution we identified is use taglibs to interact with the ejb layer.
    jsp will use this tag lib to interact with the business tier.

                        request/RESPONSE
                          |
                          |
                         -----------------------
                           jsp ------->TAGLIBS
                                         |
                         ----------------|------
                                     EJB LAYER

    Is there any one else who uses such architecture ?
    What are the other advantages and disadvantages of this architecture ?
  2. Taglibs ARE servlets. So what the reason to invent a wheel instead of directly using servlets.

    Alex.
  3. The architecture you've just presented is a part of the larger pattern called MVC-2. Struts framework is the sample implementation of this pattern (check: http://jakarta.apache.org/struts/index.html). The idea beside the pattern is very simple and staightforward (it was first introduced in Smalltalk). Application is based on:
    - Model - which in fact is application logic (EJB's etc.)
    - Controller - which is responsible for navigation, workflow and communication between presentation and model
    - View or Presentation - which contains only look and feel

    The basic benefits of using this patterns in J2EE-based applications are:
    - Separation of presentation layer - no Java in JSP's (JSP's are for webmasters, graphicians and all tag-oriented people, they are not supposed to know or learn Java)
    - Separation of logic layer - components are built to be reused between applications with different look and feel (example: WAP and WWW banking application)
    - Separation of web-flow (workflow) - the webmasters are not hardcoding links inside JSP's. They are using symbolic names or "actions". One can easily change navigation without altering web-pages.

    There is a lot of information about MVC and MVC-2 on the network. There is also a lot of open source implementations (Struts is only a sample).

    MVC-2 is a very good and usefull pattern for large projects, when you deal with a lot of JSP's, components and user platforms (WAP, WWW, call-center etc.).

    Regards

    Wojtek
  4. Hello all.

    do comment :
    http://www.theserverside.com/patterns/thread.jsp?thread_id=22143