• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help in TRACE,DELETE,PUT,HEAD

 
Karthik Rajendiran
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • 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 .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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: 218
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic