• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HEAD, DELETE, PUT, OPTIONS, Requests

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do anyone of you know how can I trigger this methods?

Thanks in advance.
 
Ian Perkins
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You could try the following:
import java.net.*
public class HttpClient {

public static void main(String[] args) {
URL url = new URL("http://localhost:8080/MyApp/servlet/MyServlet");
URLConnection conn = url.openConnection();
if (conn instanceof HttpURLConnection) {
HttpURLConnection httpConn = (HttpURLConnection)conn;
httpConn.setRequestMethod("HEAD");

httpConn.connect();
// then use various methods to extract response code, headers etc
// for example (j2se 1.4 only)...
Map m = httpConn.getHeaderFields();
}
}
}
I was also looking for a way to send the other method types to a servlet and came across the above in a Sun tech tip. There are a few strange things (like how to pass parameters in a POST) but basically it seems to behave as expected...
HTH
 
Ivan Matmati
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do it with a telnet client too and no need of a jvm:
example
telnet xxx 8080

if you want more information in different HTTP requests, have a look at the RFC for HTTP.
Good luck.
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you guys! but just one more question, Ivan, I my telnet (windows 2000) does not show any thing in the screen!! is it a problem with my operating system?
 
Ivan Matmati
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's about this devil microsoft!
No, seriously, you have to type :
telnet
prompt > set localecho
reply
prompt > open xxxx yy.

that's all.
Good luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic