Connecting to a Servlet from a client application.
Hi,
I'm trying to connect to a servlet from a client application using the following code:
StringBuffer sb = new StringBuffer();
String str = "testing...";
sb.append("message=");
sb.append(java.net.URLEncoder.encode(str));
URL url = new URL("http://localhost:8080/servlet/ServerSmar");
connection = url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
PrintWriter out = new PrintWriter(
connection.getOutputStream());
out.print(sb.toString());
.....
,where connection is a URLConnection object.
I tested the Servlet from a Web Browser and it's running ok! But when I try to access from inside my application i get no answer! The service's servlet method is not called!
I would like to know how to solve this problem.
Thanks,
Davi

