• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help in TRACE,DELETE,PUT,HEAD

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I need some help regarding the HTTP methods (TRACE,DELETE,PUT,HEAD).

PROBLEM EXPLAINED
------------------
I want to request from html to servlet using these methods.As the HTML FORM method attribute supports only get or post, we cannot request use other methods for the <FORM METHOD=""> attribute.
While searching in our forum, i found the following thread

If you want a servlet to respond to other request types, use java.net.HttpURLConnection.setRequestMethod("TRACE");
A URL created with a string starting "http://" will give you a HttpURLConnection from the getConnection method.




Can anybody please explain me
1. How to request via other http methods
2. how can i make my servlet to respond to these requests
3. What is the purpose of the HttpURLConnection
Thanks in advance
If we are going to write the
java.net.HttpURLConnection.setRequestMethod("TRACE"); in the servlet class,
then it wont work as
servlet comes into picture only after the request from page.

Can anyone please throw some examples with little explanation. I kindly request people to post with example.

SECOND QUESTION
What is the use of HttpURLConnection class. What is the purpose of that.
Explain me in detail.
Thanks in advance
FYI: I want to learn how these methods work .
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1.How to request via other http methods
2. how can i make my servlet to respond to these requests
3. What is the purpose of the HttpURLConnection


1. The example you found shows you. A form's method attribute can only take get or post as a value as you seem to know, so you need to explicitly set the request method.
2. By using the defined doTrace, doHead etc. methods of HttpServlet. As the docs say though there is almost no reason to change how these behave.
3. Its used to make an HTTP request, as it says in the JavaDocs.
 
Karthik Rajendiran
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
I understood your reply. Can you give some example program explaining how to set the requests explicitly.
One more thing.
I have to run this program [program to set explicit request]
to the server.
am i right?

Can you illustrate the setting request through some program as i am unaware of java.net package
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i am unaware of java.net package


Well,you will need to become aware of it in order to use HttpURLConnection. The java.net package has been a part of the standard library since before version 1.02 - providing these functions as part of the basic language was one reason for the rapid adoption of Java.
See the setRequestMethod documentation for how to do a HEAD or TRACE request. As I recall, rfc2616 is the standard documentation on the interpretation of these requests.
Bill
 
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
It would also be a good idea to at least browse the httpclient libraries at:
http://jakarta.apache.org/commons/httpclient.
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic