![]() |
Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
I am trying to create a servlet that serves as a broker within a 'web services' model. An example GET request that I'll generate to send out to the service might be: I send this string using a simple URLConnection Object, for example: URL url = new URL("http://10.3.1.56/imageserver.asp"); Now I want to get my response off that connection: BufferedInputStream in = new BufferedInputStream(connection.getInputStream()); The problem is that I do not always know what I will get back. If the image is unavailable or my request string is bad, I'll get an XML error message back...like: Finally, I guess (low confidence here), I want to transfer the data from the 'in' buffer array to the 'out' buffer array and then do a out.flush(). Is that smart? I also thought to use the read(byte array) method like: while(in.read(out)); but I get an error stating 'in' is not a buffer array. What?
Question 2.) Java documentation for BufferedInputStream states that it creates a buffered array..."When the BufferedInputStream is created, an internal buffer array is created." WHere is it? Question 3.) How should I work with transfering binary data from one buffer array to another? (Perhaps an example from question 1 makes this clear.) Does the flush write it out like I think it does? Question 4.) How should I deal with the fact, I may get two types of data back(binary or XML text) and its unknown when? I sincerely thank you for a response and will be happy to share results afterward. Regards, Replies:
|
Sponsored Links
|