D
Donkey Hottie
Following code does not connect
URL url = new URL("http://localhost:8090/myapp/logger");
URLConnection connection = url.openConnection();
logger.finest("[url class: " + connection.getClass().getName() + "]") ;
connection.setDoInput(false);
connection.setDoOutput(true);
connection.setAllowUserInteraction(false);
((HttpURLConnection) connection).setRequestMethod("POST");
connection.connect() ;
OutputStreamWriter outstream = new OutputStreamWriter
(connection.getOutputStream(), getEncoding()) ;
outstream.write("message=" + output) ;
outstream.flush();
outstream.close();
logger.finest("[Sent a message]") ;
Logger logs as follows:
6.10.2008 18:10:39 (http-0.0.0.0-8090-Processor25)
[MyHTTPHandler] publish FINEST - [entering,
url=http://localhost:8090/myapp/logger]
6.10.2008 18:10:39 (http-0.0.0.0-8090-Processor25)
[MyHTTPHandler] publish FINEST - [url class:
sun.net.www.protocol.http.HttpURLConnection]
6.10.2008 18:10:40 (http-0.0.0.0-8090-Processor25)
[MyHTTPHandler] publish FINEST - [Sent a message]
So, it flows the code thru, and tells everything went fine. Even if I give
an invalid URL to it! No exceptions, no errors.
When I enter the URL to a browser, the servlet there responds and works
fine. But it never sees this client code.
Any ideas?
This is running on J2EE 1.4.2 on a JBoss server.
URL url = new URL("http://localhost:8090/myapp/logger");
URLConnection connection = url.openConnection();
logger.finest("[url class: " + connection.getClass().getName() + "]") ;
connection.setDoInput(false);
connection.setDoOutput(true);
connection.setAllowUserInteraction(false);
((HttpURLConnection) connection).setRequestMethod("POST");
connection.connect() ;
OutputStreamWriter outstream = new OutputStreamWriter
(connection.getOutputStream(), getEncoding()) ;
outstream.write("message=" + output) ;
outstream.flush();
outstream.close();
logger.finest("[Sent a message]") ;
Logger logs as follows:
6.10.2008 18:10:39 (http-0.0.0.0-8090-Processor25)
[MyHTTPHandler] publish FINEST - [entering,
url=http://localhost:8090/myapp/logger]
6.10.2008 18:10:39 (http-0.0.0.0-8090-Processor25)
[MyHTTPHandler] publish FINEST - [url class:
sun.net.www.protocol.http.HttpURLConnection]
6.10.2008 18:10:40 (http-0.0.0.0-8090-Processor25)
[MyHTTPHandler] publish FINEST - [Sent a message]
So, it flows the code thru, and tells everything went fine. Even if I give
an invalid URL to it! No exceptions, no errors.
When I enter the URL to a browser, the servlet there responds and works
fine. But it never sees this client code.
Any ideas?
This is running on J2EE 1.4.2 on a JBoss server.