wood burning stoves 2.0*
The moose likes Java in General and the fly likes HTTP Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HTTP Request" Watch "HTTP Request" New topic

HTTP Request

Peter Franz

Joined: Feb 07, 2002
Posts: 15
I couldn't find out how to make a simple HTTP-Request (like one in the Browser) from a java application (J2SE).
Response from Server can be ignored, i just want to make the request with a few GET data.
e.g.: request("http://www.xyz.com?name=info&atr=3");
Is this possible?
Thanks a lot for your help!
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
It's certainly possible. I've seen more than one Java-based web browser.
I've used two testing tools that are capable of making various http requests. You might want to take a look at how HtmlUnit or HttpUnit accomplish it. They're both open source projects listed at SourceForge.net.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Also, something in the java.net package might get the job done easily for you. HttpURLConnection looks promising.
[ June 23, 2003: Message edited by: Dirk Schreckmann ]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here's something I have used to fetch HTML pages. For images or other binary files, you might want to read bytes instead of lines.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link: http://aspose.com/file-tools
subject: HTTP Request
Similar Threads
How to make a 'post' request from an application to a Servlet
to copy a policy file from server machine to client machine in java
New threads in J2EE application
Mutiple Http Request
Redirecting to HTTPS