• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

HEAD, DELETE, PUT, OPTIONS, Requests

 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do anyone of you know how can I trigger this methods?

Thanks in advance.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic