Can't invoke the Servlet............

Hi there!!

I'm trying to invoke my servlet from inside my simple Java Application.Though it shows me it has connected to the target URL but the servlet doesn't start its exceution,,here's my code...

System.out.println("========GOING FOR SERVLET=============");

URL url = new URL("http://localhost:8084/servlets-examples/servlet/HelloWorldExample");

URLConnection con = url.openConnection();

// inform the connection that we will send output and accept input

con.setDoInput(true);

con.setDoOutput(true);

con.setUseCaches (false);

con.setDefaultUseCaches (false);

con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

System.out.println("?Connected to URL");

......urgent help reqd plz.......thanks in advance...

[822 byte] By [Kami_Pakistana] at [2007-11-26 18:39:06]
# 1
That is because you are not opening an inputstream to read the response. And since you set doOutput to true, you probably need to open an outputstream first as well.
gimbal2a at 2007-7-9 6:13:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks gimbal2 for your response but now I'm getting one more problem,,,I'm encountering an exception which is...........

java.io.IOException: Server returned HTTP response code: 405 for URL: http://localhost:8084/servlets-examples/servlet/HelloWorldExample

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1174)

hope you would respond,,,thanks in advance...

Kami_Pakistana at 2007-7-9 6:13:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...