Choose the statement that best describes how to connect JSP pages and Enterprise JavaBeans (EJBs):

  1. Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean.

  2. Lookup and use the EJBs from a separate business delegate. The JavaBeans that work with JSP pages are clients to these business delegates and know nothing about EJB specifics.

  3. Lookup and use the EJBs from within a JSP page, but only as remote references.

  4. Lookup the EJBs from within a servlet, delegating usage to specific JSP pages.


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean. This option is incorrect because it suggests using the EJBs from within a basic JavaBean, which is not the recommended approach for connecting JSP pages and EJBs.

Option B) Lookup and use the EJBs from a separate business delegate. The JavaBeans that work with JSP pages are clients to these business delegates and know nothing about EJB specifics. This option is correct because it suggests using a separate business delegate to lookup and use the EJBs. The JavaBeans that work with JSP pages act as clients to these business delegates and are unaware of the specific details of the EJBs. This approach helps to decouple the JSP pages from the EJB specifics, providing better maintainability and flexibility.

Option C) Lookup and use the EJBs from within a JSP page, but only as remote references. This option is incorrect because it suggests using the EJBs as remote references directly within the JSP page. While it is possible to do so, it is generally not recommended as it violates the principle of separation of concerns and can make the JSP page tightly coupled to the EJBs.

Option D) Lookup the EJBs from within a servlet, delegating usage to specific JSP pages. This option is incorrect because it suggests looking up the EJBs from within a servlet and then delegating usage to specific JSP pages. While this approach is possible, it is not the best practice as it introduces unnecessary complexity and violates the principle of separation of concerns.

The correct answer is B. This option describes the recommended approach for connecting JSP pages and EJBs by using a separate business delegate to lookup and use the EJBs, while the JavaBeans that work with JSP pages act as clients to these business delegates and are unaware of the EJB specifics.

Find more quizzes: