The Artima Developer Community
Sponsored Link

Java Answers Forum
How to pass byte[] from one servlet to another, which are on diff servers?

1 reply on 1 page. Most recent reply: Sep 2, 2003 12:22 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Shridhar N

Posts: 6
Nickname: shridhar
Registered: Mar, 2003

How to pass byte[] from one servlet to another, which are on diff servers? Posted: Sep 1, 2003 3:31 AM
Reply to this message Reply
Advertisement
Hi All,

Can anyone tell me how to transfer/send byte[] from servlet ( C ) another servlet ( B ) , ( and finally to last servlet ( A ) )..

Connection between A, B and C is made thru HttpURLConnection.

I tried this :

To Write Form C 2 B :

ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
byteOutStream.writeTo(response.getOutputStream());
byteOutStream.write(license FileBytes);
System.out.print("licenseFile LIA : "+licenseFileBytes);
byteOutStream.close();


Reading the same @ B:

byte[] licenseFile = new byte[500];
ByteArrayInputStream byteInStream = new ByteArrayInputStream (licenseFile);
byteInStream = (ByteArrayInputStream)urlConn.getInputStream();
The above Reading part is throwing Exception , ClassCast Exception ..

and from here i want to write the same byte[] back to A..

Can anyone tell me how to go about doing the same. using any File IO operations..

Any help would be highly appreciated..
IS THERE ANY OTHER WAY BY WHICH I CAN PASS byte[] DATA FROM ONE SERVLET TO ANOTHER..

Thanks in Advance..
~Shridhar..


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: How to pass byte[] from one servlet to another, which are on diff servers? Posted: Sep 2, 2003 12:22 AM
Reply to this message Reply
Warning:Not tested code.


Why dont u use this while Reading the same @ B:
byte [] byteArr ;
urlConn.getInputStream().read(byteArr );
byteInStream = new ByteArrayInputStream (byteArr );

Flat View: This topic has 1 reply on 1 page
Topic: Java I/O Problem(Thanks) Previous Topic   Next Topic Topic: JSP to excel error

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use