• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Generate HTTP PUT request

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to generate HTTP PUT request programatically using java.
Can anybody help on this topic.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try Jakarta HttpClient. It's free.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Something like the following will do the trick:

 
Peter Chase
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
let's slide this over to the Servlets forum, not sure that's the best place but it's better than here
 
Arpit Purohit
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not really a servlets question either (unless you need help with the doPut methdod). Moving to Sockets and Internet Protocols.
 
Arpit Purohit
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Right! We're on it! Let's get to work tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic