It's not a secret anymore!*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 12675
    
    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

Java Resources at www.wbrogden.com
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
 
Similar Threads
need some help
How do you implement Web Services security?
Getting the current directory from pageContext
How to find out the Browser's Encoding through Javascript?
Getting HttpSession from the init method