Blog de David Rodriguez

Internet, tecnologia, programacion, SEO

Lanzar una petición POST en java

Marzo 27th, 2009 by David Rodriguez


Si necesitamos realizar una petición POST desde un módulo java, se puede hacer fácilmente con este código:URL urlnew = new URL (url);
con = (HttpURLConnection)urlnew.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestMethod(“POST”);
con.setUseCaches(false);
con.setRequestProperty(“Content-type”, “application/x-www-form-urlencoded”);
con.connect();

BufferedReader in = new BufferedReader(new           InputStreamReader(con.getInputStream()));
response=in.readLine();
in.close();

 

Espero os sirva de ayuda si necesitais hacer este tipo de llamadas.

Posts relacionados

This entry was posted on Viernes, Marzo 27th, 2009 at 4:20 pm and is filed under Internet, Programacion. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply