Search code examples
jakarta-eeejbhttprequestejb-3.0

How make HTTP request from EJB?


I need to send an Http request inside a business method. Is a good practice make it using java SE API such as Httpurlconnection? Thanks for your help.


Solution

  • Yes, the specification clearly says that an EJB can be client of a webservices or socket.

    The EJB architecture allows an enterprise bean instance to be a network socket client, but it does not allow it to be a network server. Allowing the instance to become a network server would conflict with the basic function of the enterprise bean— to serve the EJB clients.

    However, it depends what you do with the stream itself. If you plan to gather data, analyze and return to presentation layer it is ok. If instead you mean to stream binaries such as a document, images to the presentation this is discouraged.