Have you ever tried to do HTTP from within Java? I am not talking about Servlet or JSP. Just plain POJO. To do this, you can use several http libraries available. Java has a built in class called HttpURLConnection to do this.

Here is a blog that discusses using this class to send/receive HTTP requests in a Java program.


You can see a little more elaborate example in Alvin Alexander’s blog below.


There are other libraries available. Like always, Apache has some libraries to do HTTP from within Java class. See this blog for an example:


Why would you want to do Java in a POJO class? May be you want to read some URL to get the content and show parts of it it in your program. Or you are doing a Web Service (SOAP or REST) to get/post some data from a Web service.

There are other libraries, like Apache Axis2, available to do Webservices in Java as well.