连接 JSP 和 EJB
如何连接 JSP 页面和 Enterprise JavaBeans?
- 从 JSP 中查找 EJB,但在基本 JavaBean 中使用 EJB?
- 从单独的业务委托查找并使用 EJB。与 JSP 页面一起工作的 JavaBean 是这些业务委托的客户端,并且对 EJB 细节一无所知?
- 从 JSP 页面内查找并使用 EJB,但仅作为远程引用?
- 从 servlet 中查找 EJB,将使用委托给特定的 JSP 页面?
How can I connect JSP pages and Enterprise JavaBeans?
- Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean?
- 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?
- Lookup and use the EJBs from within a JSP page, but only as remote references?
- Lookup the EJBs from within a servlet, delegating usage to specific JSP pages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选项#4 与委托一起使用时最合适。本质上,您需要的是关注点分离,其中每一层负责一些特定的功能。
EJB 处理数据并充当通过标准接口提供服务的业务组件
代理处理 EJB 并屏蔽任何实体,使其免受 EJB 查找和调用细节的影响。
Servlet 通过委托调用业务方法,然后将控制权连同从委托(最终从 EJB)获取的数据一起传递给 JSP
JSP 根据 servlet 传递的数据呈现视图。
这本质上是一个 MVC模式和标准推荐方法之一。请参阅以下链接 1, 2。
Option #4 is the most appropriate when used with Delegates. Essentially what you need is separation of concerns where in each layer is responsible for some specific functions.
EJBs process the data and act as business components offering services via standard interfaces
Delegates dealing with EJB and shielding any entities from details of lookup and invocation of EJB.
Servlet invoke the business methods via Delegates and then pass the control to JSP along with data obtained from Delegate (eventually from EJB)
JSP rendering the view based on the data passed by servlets .
This is essentially an MVC pattern and one of the standard recommended approaches. Please see refer to these links 1, 2.