| Author |
Need Help in TRACE,DELETE,PUT,HEAD
|
Karthik Rajendiran
Ranch Hand
Joined: Aug 13, 2004
Posts: 209
|
|
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: 209
|
|
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: 12327
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
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
|
 |
 |
|
|
subject: Need Help in TRACE,DELETE,PUT,HEAD
|
|
|