• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

StreamCorruptedException: invalid stream header

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am sending a vector from an applet to servlet.When I tried to execute applet from browser I am getting above error in the Weblogic console.

I am sending data using ObjectInputSTream...
The code is like below...
The applet:

public void sendObjToServer(Vector loginParamaters)
{
URL url = null;
URLConnection urlConn = null;
InputStream is = null;
DataOutputStream outs = null;
ObjectInputStream ois = null;
try
{
url = new URL("http://co78565:7001/test");
urlConn = url.openConnection();
urlConn.setAllowUserInteraction(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
urlConn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
ObjectOutputStream objOutStream = new ObjectOutputStream(urlConn.getOutputStream());
objOutStream.writeObject(loginParamaters);
objOutStream.flush();
objOutStream.close();
}
catch(Exception e)
{
System.out.println("Exception exp"+e);
e.printStackTrace();
}

--------------------------
in servelt:

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
ObjectInputStream inputFromApplet = null;
PrintWriter out = null;
Hashtable hashValue = new Hashtable();
try
{
inputFromApplet = new ObjectInputStream(request.getInputStream());
loginInfo = (Vector) inputFromApplet.readObject();
inputFromApplet.close();
System.out.println(" loginInfo values in servelt "+ loginInfo);
User = (String)loginInfo.elementAt(0);
pwd = (String)loginInfo.elementAt(1);
clt = (String)loginInfo.elementAt(2);
host = (String)loginInfo.elementAt(3);
lang = (String)loginInfo.elementAt(4);
sys = (String)loginInfo.elementAt(5);
R3ConnectionInfo ci = new R3ConnectionInfo(User, pwd, clt, host, sys, lang);
FunctionGroup group[] = RfcFunctionSearch.fetchRfcFunctions(ci, "Z*", null);
for (int i = 0; i < group.length; i++)
{
RemoteFunction functions[] = group[i].getFunctions();
String[] functionNames = new String[functions.length];
for (int j = 0; j < functions.length; j++)
{
functionNames[j] = functions[j].getFunctionName();
}
hashValue.put(((String)group[i].getGroupName()),functionNames);
}
}
catch(Exception e)
{
System.out.println(" Exception in doPost()"+ e);
}
System.out.println(" Hash Table output is :"+hashValue.toString());
sendBORList(response, hashValue);
}

-----------------------
ERROR in the CONSOLE:
Exception in doPost()java.io.StreamCorruptedException: Caught EOFException while reading the stream header

I am using weblogic server as app server and i am getting error at
inputFromApplet = new ObjectInputStream(request.getInputStream());
in the servlet..
Any help in this regard appriciated well.
Thanks,
Madhu Palutla
[ July 12, 2002: Message edited by: Madhu Palutla ]
[ July 13, 2002: Message edited by: Madhu Palutla ]
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's in the input stream returned by request.getInputStream(), if it's not a correctly serialised object? You should be able to get some idea by reading the stream byte by byte and printing the bytes out. One possibility (strongly suggested by the EOF exception on reading the stream header) is that there's nothing at all in the stream.
What's getting sent out by the HttpURLConnection? It manages to contact the servlet, which indicates that it's at least sending out the headers of a valid HTTP request, but possibly it's not appending the serialised object. The quick and dirty method I use is to point the url at a server that does nothing but sit on a port and print out what arrives:
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic