473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

java.io.StreamCorruptedException: invalid stream header

What does this error for the Code below
java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at com.kbs.framework.client.gui.PIPReport.doProcess(P IPReport.java:562)
at com.kbs.framework.client.gui.PIPReport.actionPerfo rmed(PIPReport.java:508)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$ForwardActionEvents.act ionPerformed(Unknown
Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown
Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

When I click the Button in Applet , I want it open a Dialog asking for
the excel to open/save etc... It doesnt happen why...

Though I'm writing the contents to excel , Now it doesnt create the
excel file Why....
My Applet code is
------------------------------------------------------------------------------
URL url =new URL("http://localhost:8080/portal/servlet/com.kbs.framework.client.gui.ReportServlet");

HttpURLConnection servletConnection =
(HttpURLConnection)url.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);

servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestMethod("POST");
servletConnection.setRequestProperty("Content-type","application/octet-stream");

ObjectOutputStream outStream =
new ObjectOutputStream(servletConnection.getOutputStre am());
outStream.writeObject(command);
outStream.flush();
outStream.close();

System.out.println("MY RESULT IN APPLET");
InputStream instr = servletConnection.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String result = (String) inputFromServlet.readObject();
inputFromServlet.close();
instr.close();
------------------------------------------------------------------

SERVLET CODE
--------------------------------------------------------------------
public void performTask(javax.servlet.http.HttpServletRequest
request,javax.servlet.http.HttpServletResponse response)
{
response.setContentType("application/vnd.ms-excel");
PrintWriter out = response.getWriter();
String fileName = "temp" + Long.toString(System.currentTimeMillis())
+ ".xls";
response.addHeader("Content-Disposition", "inline; filename=\"" +
fileName
+ "\"");
InputStream in = request.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in);
String command = (String) inputFromApplet.readObject();
String result = submitQuery(command);
System.out.println("RESULT" + result);
out.println(command);
out.close();
--------------------------------------------------------------
Jul 17 '05 #1
2 47232
"SubbaRao Karanam" <su************@yahoo.com> wrote in message
news:5d**************************@posting.google.c om...
What does this error for the Code below
java.io.StreamCorruptedException: invalid stream header *snip stacktrace*

When I click the Button in Applet , I want it open a Dialog asking for
the excel to open/save etc... It doesnt happen why...

Though I'm writing the contents to excel , Now it doesnt create the
excel file Why....
My Applet code is
-------------------------------------------------------------------------- ---- URL url =new URL("http://localhost:8080/portal/servlet/com.kbs.framework.client.gui.Repor
tServlet");
HttpURLConnection servletConnection =
(HttpURLConnection)url.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);

servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestMethod("POST");
servletConnection.setRequestProperty("Content-type","application/octet-strea
m");
ObjectOutputStream outStream =
new ObjectOutputStream(servletConnection.getOutputStre am());
outStream.writeObject(command);
outStream.flush();
outStream.close();

System.out.println("MY RESULT IN APPLET");
InputStream instr = servletConnection.getInputStream();
ObjectInputStream inputFromServlet = new ObjectInputStream(instr);
String result = (String) inputFromServlet.readObject();
inputFromServlet.close();
instr.close();
------------------------------------------------------------------

SERVLET CODE
--------------------------------------------------------------------
public void performTask(javax.servlet.http.HttpServletRequest
request,javax.servlet.http.HttpServletResponse response)
{
response.setContentType("application/vnd.ms-excel");
PrintWriter out = response.getWriter();
String fileName = "temp" + Long.toString(System.currentTimeMillis())
+ ".xls";
response.addHeader("Content-Disposition", "inline; filename=\"" +
fileName
+ "\"");
InputStream in = request.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in);
String command = (String) inputFromApplet.readObject();
String result = submitQuery(command);
System.out.println("RESULT" + result);
out.println(command);
out.close();
--------------------------------------------------------------


Compilable code is preferable. For tips on future posts, see:
http://www.physci.org/codes/sscce.jsp

From what you provided, I would assume you're attempting to use an
ObjectInputStream to receive data from a PrintWriter. How do you expect that
to work? You're getting a StreamCorruptedException because an
ObjectInputStream expects to read an object stream, i.e. the other end of an
ObjectOutputStream.
Jul 17 '05 #2
meena
1
Hi
I am trying to call the servlet's dopost method through my java program. I am supposed to give a file through my java program to the servlet and servlet has to save the same in the specified location. I was searching for the code, I found you are also trying to do the same. Please let me know whether you got any solution for your problem. Can you please post your code.

thanks in advance.

regards
Mar 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick Nygaard | last post by:
Hi everyone, I'm using O'Reilly's servlet API to make an object based HTTP communication between an Applet and a servlet. Following their own tutorial 10.2.3. Object-based HTTP Communication...
0
by: CSN | last post by:
There are a bunch of these in PG's log: ERROR: Invalid page header in block 14 of start_items_key What does it mean? PG seems to be working fine - anything I need to fix/adjust/worry about?...
1
by: Carmen Wai | last post by:
Hello: I am a new user of postgresql. I am using postgresql 7.3.4 and I had inserted about 1.7 million records to a table. When I vacuum / select * from table, it gets a error message of :...
0
by: Konstantinos Agouros | last post by:
Hi, I have a machine that is currently a bit unstable. No I got a: sysad=# select * from attacks where start < '1.1.2000'; ERROR: Invalid page header in block 3618 of attacks From googeling...
2
by: Anthony | last post by:
Our Database is having errors. We are currently using PostgreSQL to store 2.5 Million records per day. The average addition to our primary table is 4.5 Gigs of data. We are doing this on a dual...
0
by: Hubert Fröhlich | last post by:
Hi list, I am working with 7.4.1 under Linux (SuSE 8.1) The server is a HP ProLiant DL 380-G3, 2x Intel Pentium4-Xeon, 2.8 GHz, 4 GB memory and a RAID 5 system with ca. 500 GB diskspace (xfs...
5
by: Ed L. | last post by:
I have 5 corrupted page headers as evidenced by these errors: ERROR: Invalid page header in block 13947 of ... The corruption is causing numerous queries to abort. First option is to try to...
5
by: Steve Crawford | last post by:
This morning I got bitten by the "SELECT INTO" / "CREATE TABLE AS" from tables without OIDs bug in 7.4.1. Postmaster killed all the backends and restarted - pg was down for 2 seconds. This...
6
by: sapsi | last post by:
Hello, I am using HadoopStreaming using a BinaryInputStream. What this basically does is send a stream of bytes ( the java type is : private byte bytes) to my python program. I have done a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.