This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes GET Request from inside a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "GET Request from inside a Servlet" Watch "GET Request from inside a Servlet" New topic
Author

GET Request from inside a Servlet

Marco Zanini
Ranch Hand

Joined: Oct 31, 2011
Posts: 43
Hi to all, I'm trying to make a GET HTTP request to a remote URL from inside a Servlet. Which library should I use? I would like to avoid using URLFetch because I found it's really low-level. Can I use a library where I can have a HttpRequest object or something like that where I can add parameters like object.addParameter(name, value)? I don't understand why a library like that is not available. I just want to be sure that doesn't exist other better libraries before start using URLFetch.

Many thanks
Cole Terry
Ranch Hand

Joined: Nov 23, 2011
Posts: 45
Hi,

You can use the URLConnection class in the package java.net.* to make a GET/POST request to a remote URL.

Hope this helps.
Marco Zanini
Ranch Hand

Joined: Oct 31, 2011
Posts: 43
Thanks, I was just asking if there's something more high-level.
I have to extract from the response some parameters and I want to avoid parsing a String manually.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
The Apache Software Foundation project named HttpComponents has taken over the HTTPClient toolkit. A very complete and well debugged set of tools and of course open source.

Bill
Marco Zanini
Ranch Hand

Joined: Oct 31, 2011
Posts: 43
Thanks that's what I was looking for!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GET Request from inside a Servlet