Http Post

Following code I m using for http posting. It is working fine. But from some URL, it is not getting any response and throws IO Exception on some m/c.

I tried with all the version of java. And I am using java 6 now.

It is working well, while running (posting) with my pc. But it throws exception on another m/c. [and for your information, that m/c is having Global IP & behind firewall.]

/*

post ( String url_to_post )

*/

URL url;

url =new URL ( url_to_post );

HttpURLConnection url_con ;

url_con = (HttpURLConnection)url.openConnection ();

url_con.connect();

int statusCode = url_con.getResponseCode();

System.out.println("statusCode"+statusCode);

InputStream _is =null;

try{

if ( statusCode<=400)

{

_is = url_con.getInputStream();

}

else{

_is = url_con.getErrorStream();

}

}

catch (IOException e){

throw e;

}

BufferedReader buffer =new

BufferedReader(new InputStreamReader (_is));

String result = buffer.readLine() ;

return result;

[1773 byte] By [azhagana] at [2007-11-26 18:10:00]
# 1
> behind firewallThat should be the problem.
hiwaa at 2007-7-9 5:42:08 > top of Java-index,Core,Core APIs...
# 2
Application throws exception when posting to some url only. But the same url is working from other m/c.
azhagana at 2007-7-9 5:42:08 > top of Java-index,Core,Core APIs...
# 3
And once again, the firewall is probably the problem.What exception exactly are you getting? I'm betting something do with the connection attempt. Which, once again, is (with about 99.99999% probability) caused by the firewall.
masijade.a at 2007-7-9 5:42:08 > top of Java-index,Core,Core APIs...
# 4
if firewall is the problem, then HOW Other url are working fine. it throws exception when submitting to some particular url.&url which gives problem, is working well with my pc.so what is the solution...
azhagana at 2007-7-9 5:42:08 > top of Java-index,Core,Core APIs...
# 5
Firewall configuration issue ...
hiwaa at 2007-7-9 5:42:08 > top of Java-index,Core,Core APIs...
# 6
but i opened the same url using IE. i got result. still it would be firewall related issue...?
azhagana at 2007-7-9 5:42:08 > top of Java-index,Core,Core APIs...