aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Generate HTTP PUT request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Generate HTTP PUT request" Watch "Generate HTTP PUT request" New topic
Author

Generate HTTP PUT request

Arpit Purohit
Greenhorn

Joined: Jan 09, 2007
Posts: 21
I want to generate HTTP PUT request programatically using java.
Can anybody help on this topic.


Regards,
Arpit Purohit
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Try Jakarta HttpClient. It's free.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42926
    
  68
Welcome to JavaRanch.

Something like the following will do the trick:

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Yes, it depends how advanced your usage will be. Plain JDK Java will do for the simplest cases, but Jakarta HTTPClient will help a lot with more-difficult cases.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
let's slide this over to the Servlets forum, not sure that's the best place but it's better than here


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Arpit Purohit
Greenhorn

Joined: Jan 09, 2007
Posts: 21
Hi friends,
let me make it more clear about HTTP PUT request.
It is used to create new resource on server.And same i want to do programatically.
Can anybody give me example for that?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42926
    
  68
Can you be more specific what you're trying to do? Peter and myself mentioned two possibilities how to send a request from the client side; on the server side you can use a servlet's doPut method. If that doesn't help, tell us where you're stuck implementing this, and we'll try to get you going again.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Not really a servlets question either (unless you need help with the doPut methdod). Moving to Sockets and Internet Protocols.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Arpit Purohit
Greenhorn

Joined: Jan 09, 2007
Posts: 21
Being more specific,
I want to create a resource on server by sending PUT request from the client (which is the basic usage PUT request ). I know very well that PUT request is handled on server side (servlet) using doPut() method. But i am not clear about following things:

1. How can i generate PUT request from client (say java program)?
2. Further, how and what to handle on servet's doPut() method so as to create
resource?
3. As known, PUT request is to create resource on server, do i have to provide
resource name(to be created) as parameter in the request and how?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42926
    
  68
1. How can i generate PUT request from client (say java program)?

Paul and I mentioned two ways of doing this. What else are you looking for?

2. Further, how and what to handle on servet's doPut() method so as to create resource?

3. As known, PUT request is to create resource on server, do i have to provide resource name(to be created) as parameter in the request and how?

Conceptually, a PUT is somewhat similar to a POST, with the body of the request containing the resource. So you'd use the Request.getInputStream method to get at the data of the resource.

The name of the resource is the URI (or URL in this case), so no extra name is supplied. You should read section 9.6 of the HTTP specification (and the other sections it points to) for further details regarding the implementation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generate HTTP PUT request