Hi,
I have a Tomcat server running at port 8080 (thru jbuilder). I have written the following client code:
BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
message = messageText.getText();
URL u = new URL ( "http://localhost:8080/Servlet1?Message=" + message );
HttpURLConnection con = (HttpURLConnection) u.openConnection ();
con.setDoInput(true);
con.setRequestMethod("GET");
con.connect();
con.getResponseMessage();
javax.swing.JOptionPane.showMessageDialog ( null, "Message Sent" );
con.disconnect ();
Basically, the server just has to read the parameter 'message' and store it in a database. When i type this exact url in the browser, it works. But when i run the above code in an application of my own, I get the following exception:
java.io.FileNotFoundException <followed by the complete url>
However, this message doesn't come if i remove the 'con.getResponseMessage();' line from the code. And whether or not this line is there, nothing gets written on the database!!!!
if the url works from the browser, how come i get this message. Please tell me how can i make my application work?


Reply With Quote


Bookmarks