Discussions

EJB design: Better Design for system

  1. Better Design for system (4 messages)

    Hi All,

    I have a current architecture which I think could be imporved.

    It goes as follows

    1)html page to call servlet_1,
    2)servlet_1 then calls EJB
    3)jsp then calls a proxy_servlet which calls servlet_1 which calls EJB and populates jsp with values.

    Is there a better way to do this?

    Threaded Messages (4)

  2. Better Design for system[ Go to top ]

    Hi,
    could u give more info on what servlet_1 is being used for??is it acting like a controller??
  3. Better Design for system[ Go to top ]

    Servlet_1 manipulates the data entered in the html page to format it properly for the EJB. I have looked at patterns for getting back data to the EJB to the JSP. The only one I came across was the proxy type pattern. Where the JSP talks to the proxy_servlet which talks to the EJB (Stateful session). I am using Websphere 3.52 advanced edition. That might have some bearing on what options are available to me.

    Berb.
  4. Better Design for system[ Go to top ]

    Berb,

    I would recommend the following pattern:

    1) client sends Request to servlet_1,

    2) servlet_1 then calls EJB, and gets some data
    3) servlet_1 stores data in HttpSession
    4) servlet_1 forwards Req/Resp pair to the appropriate jsp

    5) jsp pulls data from HttpSession
    6) jsp builds page
    7) jsp sends response to client

    8) go to line 1...


    This has a quite a few benefits:
    - Only need to write one servlet for many JSPs.
    - The JSP writer does not need to worry about navigation, since the Servlet handles it.
    - JSP code is simpler since there is no need to call EJB.
    - If there are any future changes or additions you will only need to update the Servlets navigation routine.

    As you can see I would strongly disagree with Deepika, since I prefer to control the level of interaction by various parts of the system.

    -JC

  5. Better Design for system[ Go to top ]

    Your JSP can call your entity/session bean directly.
    Html calling a servlet, or JSP calling a servlet is redundant.
    Create your JSP which separates the design from your data, and invoke your bean from JSP.

    Hope this helps you :-)