Calling Java Beans from JSP

Discussions

EJB design: Calling Java Beans from JSP

  1. Calling Java Beans from JSP (1 messages)

    Hi All,

    I'll like to get an insight reagarding a design pattern.

    Sometime speople use taglib concepts of JSP to call a Java Bean which internally gets data from the ejb tier (in general from the model). The contol flows like this -
    The request comes to servlet,
    The servlet handles the request to the appropriate JSP,
    The JSP gets the data from the model tier using taglib/Java Beans etc.

    The alternate approach is -
    The request come to servlet,
    Servlet passes the request to Model tier using command pattern/business delegate pattern etc and get the data.
    Then appropriate JSP is called. The data (which is obtained in the previous step) to be populated in JSP is passed through the request object itself.

    Can anyone please tell me which one is the better approach ?

    Regards,
    Sourav
  2. The second approach is MUCH better. TagLibs should only use data that is available to/attached to the request. A Tag should know nothing of the EJB tier.

    I've seen a Tag make JDBC calls before. Ouch! Bad, Bad!