Search code examples
jakarta-eejerseyjax-rsjersey-clientjava-ee-7

Can Java EE Application Make HTTP Calls?


Can a Java EE Application -- a Servlet or a Session Bean -- make HTTP calls and still conform to portability standards? (assuming that the caller gracefully handles communication failure or unavailability of network)

Furthermore, can a Java EE 7 application count on availability of JAX-RS client to access REST-like resources?


Solution

    1. You can make HTTP calls from Servlet or Session Bean (as long as you are not trying to do that in a separate thread). In general, you can open client socket in EJB Bean or Servlet.

    2. JAX-RS 2.0, which is a part of Java EE 7 has client API (see this excelent article: http://www.oracle.com/technetwork/articles/java/jaxrs20-1929352.html)