Hellu, Please some HTTP response help as it drives me grazy. I have a tiny java program (originaly it is part of the EJB but I extrated it to a stand-alone program for testing) that opens a Url connection and sends something through a Stream. It then reads the response from the input stream. The strange thing is that some a jsp, and asp give me an error when trying to open the input stream when to get the respons. I am a bit confused and don't know the exact requirements of the receiving side to not receive this respons error. When I make connection to an empty asp I don't have any error, but to an asp that has some code, I do get an error. When calling my servlets I don't get any error. it looks like the called page should return something in a proper way otherwhise the receiving side doesn't understand it... or something like that. Search a lot on the web..... nothing :( Please some help on this.
Here is the code snap, used trying to solve the problem : ----------------- public static void main(String[] args) { HttpURLConnection connection=null; DataOutputStream out=null; if (args.length!=1) { System.out.println("To less input parameters detected"); System.exit(-1); } String url=args[0]; try { System.out.println("Trying to connect to "+url); URL urlCon = new URL(url); // open connection with remote server connection = (HttpURLConnection) urlCon.openConnection(); connection.setDoOutput(true); // indicate the we want to write output. connection.setDoInput (true); // indicate the we expect input. connection.setUseCaches (false); // no cache. String bla="SOMETHING"; connection.setRequestProperty("CONTENT_LENGTH", "" + sms.length()); out = new DataOutputStream(connection.getOutputStream()); System.out.println("Trying to send: "+bla); out.writeBytes (bla); out.flush (); out.close(); // free shared resources. // Getting response code/string from remote server. DataInputStream input; InputStream resStrm = connection.getInputStream (); // HERE IS WERE COMPLAINS. int res = connection.getResponseCode(); System.out.println("Return: "+res); input = new DataInputStream (resStrm); String str; while (null != ((str = input.readLine()))) System.out.println (str); ----------------- The error: -------------- java.io.FileNotFoundException: http://10.17.17.213/m2u/interfaces/g aap.asp at sun.net.www.protocol.http.HttpURLConnection.getInputStre am(Unknown Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source) at connect2Url.main(connect2Url.java:49) --------------- The test jsp to receive it, that doesn't work: -------------------- System.out.println("Receiving something"); BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream())); String inputLine = ""; String totLine = ""; while ((inputLine = in.readLine()) != null) { totLine = totLine + inputLine; } in.close(); // close input stream. System.out.println("Received: "+totLine); response.setContentType("text/html"); response.setStatus(200); -------------------- When I call an empty asp page it all goes well ... :( Regards, Ed Bras >