wood burning stoves 2.0*
The moose likes Servlets and the fly likes Need Help in TRACE,DELETE,PUT,HEAD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Need Help in TRACE,DELETE,PUT,HEAD" Watch "Need Help in TRACE,DELETE,PUT,HEAD" New topic
Author

Need Help in TRACE,DELETE,PUT,HEAD

Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
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 .


SCJP 1.4 SCWCD 1.4 SCDJWS 1.4
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Karthik Rajendiran
Ranch Hand

Joined: Aug 13, 2004
Posts: 211
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Dec 11, 2004
Posts: 13410

It would also be a good idea to at least browse the httpclient libraries at:
http://jakarta.apache.org/commons/httpclient.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help in TRACE,DELETE,PUT,HEAD
 
Similar Threads
POST method - unintended side effects
Can't use trace, put, delete methods on tomcat
Safe and Idempotent methods
Invoking HTTP Methods
sending PUT,DELETE requests to HttpServlet (urgent)