Hellu,

I did some more testing and discovered where the problem is.
When I do return a return code of for example 400 or 500 I get the error
listed below. If I set a return code 200 in my jsp it all works fine ... I
did the same test with a asp page and got the same error.
Hmmm strange... Can someone explain this ..... or this some kind of bug ??
The code in my main to test it all:
-------------
 BufferedWriter out = new BufferedWriter(new
OutputStreamWriter(connection.getOutputStream()));
 out.write(sms,0,sms.length());
 out.close();

 BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
 String inputLine;

 while ((inputLine = in.readLine()) != null)
     System.out.println(inputLine);

 in.close();
-------------

The  JSP that is called:
--------------
    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(400);
 out.println("bla");
-------------

En de error:
--------------
java.io.FileNotFoundException:
http://localhost:9000/groupsend/bla/receiveStrm.jsp
        at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at java.net.HttpURLConnection.getResponseCode(Unknown Source)
        at connect2Url.main(connect2Url.java:57)
--------------

Please some help,
Ed Bras


----- Original Message -----
From: "Eddie" <
[EMAIL PROTECTED]>
To: "Orion-Interest" <
[EMAIL PROTECTED]>
Sent: Wednesday, November 14, 2001 9:10 AM
Subject: HTTP response help please ?


> 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
> >
>
>
>

Reply via email to