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