This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes How to trigger HTTP requests Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "How to trigger HTTP requests" Watch "How to trigger HTTP requests" New topic
Author

How to trigger HTTP requests

Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Hello all

I understand we can send HTTP GET and POST requests from a browser to a web server(via hyperlinks, and form fields etc). I wanted to know how do we trigger the other HTTP methods like GET, HEAD, PUT, TRACE, DELETE etc...


Success is never ending and Failure is neve Final
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
I do not think that browser uses any other method other than GET , POST.

You can have your own application making use of the other methods.

You can writing a program to make a report of all the resources available at URL (URL's will be given to you).In that case you can issue a GET command.But you purpose is just to see whether resources are available or not , not to get the resource content.So you can make use of HEAD method instead of GET.


Rahul Bhattacharjee
LinkedIn - Blog
Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Hi Rahul,

I know a browser can only trigger GET and POST request. I wanted to know what are the other ways, if there are any, to trigger PUT, DELETE, TRACE, HEAD request. They need not be from a browser.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
A browser can send any HTTP method via the JavaScript XmlHttpRequest object.

A Java client like java.net.URLConnection or Jakarta Commons HttpClient can also do that.


Ping & DNS - my free Android networking tools app
Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Hi Ulf,

Could you share with me a sample program on how to issue a PUT request?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
This is a good starting point.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
My wiki server records HEAD requests when I download files. That gives the browser the information to fill in the "nnn bytes of nnn bytes" on the download progress. (Hmmm, just checking the log I don't see any. Wonder if I imagined that?) Somebody sends OPTIONS requests now and then, too. I don't know how they do it; I haven't been able to make my browser send that one.


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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41631
    
  55
My wiki server records HEAD requests when I download files. That gives the browser the information to fill in the "nnn bytes of nnn bytes" on the download progress.


That sounds a bit odd. After all, the HTTP header contains the length of the response, and since the browser knows how many bytes it has read so far, there should be no need to communicate with the server.

I could imagine a browser sending HEAD requests to check if a particular resource has changed since the browser last requested (and cached) it; particularly for large files. Although that's really what conditional GET is for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to trigger HTTP requests