What does this error for the Code below
java.io.StreamC orruptedExcepti on: invalid stream header
at java.io.ObjectI nputStream.read StreamHeader(Un known Source)
at java.io.ObjectI nputStream.<ini t>(Unknown Source)
at com.kbs.framewo rk.client.gui.P IPReport.doProc ess(PIPReport.j ava:562)
at com.kbs.framewo rk.client.gui.P IPReport.action Performed(PIPRe port.java:508)
at javax.swing.Abs tractButton.fir eActionPerforme d(Unknown Source)
at javax.swing.Abs tractButton$For wardActionEvent s.actionPerform ed(Unknown
Source)
at javax.swing.Def aultButtonModel .fireActionPerf ormed(Unknown Source)
at javax.swing.Def aultButtonModel .setPressed(Unk nown Source)
at javax.swing.pla f.basic.BasicBu ttonListener.mo useReleased(Unk nown
Source)
at java.awt.Compon ent.processMous eEvent(Unknown Source)
at java.awt.Compon ent.processEven t(Unknown Source)
at java.awt.Contai ner.processEven t(Unknown Source)
at java.awt.Compon ent.dispatchEve ntImpl(Unknown Source)
at java.awt.Contai ner.dispatchEve ntImpl(Unknown Source)
at java.awt.Compon ent.dispatchEve nt(Unknown Source)
at java.awt.Lightw eightDispatcher .retargetMouseE vent(Unknown Source)
at java.awt.Lightw eightDispatcher .processMouseEv ent(Unknown Source)
at java.awt.Lightw eightDispatcher .dispatchEvent( Unknown Source)
at java.awt.Contai ner.dispatchEve ntImpl(Unknown Source)
at java.awt.Compon ent.dispatchEve nt(Unknown Source)
at java.awt.EventQ ueue.dispatchEv ent(Unknown Source)
at java.awt.EventD ispatchThread.p umpOneEventForH ierarchy(Unknow n
Source)
at java.awt.EventD ispatchThread.p umpEventsForHie rarchy(Unknown Source)
at java.awt.EventD ispatchThread.p umpEvents(Unkno wn Source)
at java.awt.EventD ispatchThread.p umpEvents(Unkno wn Source)
at java.awt.EventD ispatchThread.r un(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.framewo rk.client.gui.R eportServlet");
HttpURLConnecti on servletConnecti on =
(HttpURLConnect ion)url.openCon nection();
servletConnecti on.setDoInput(t rue);
servletConnecti on.setDoOutput( true);
servletConnecti on.setUseCaches (false);
servletConnecti on.setDefaultUs eCaches(false);
servletConnecti on.setRequestMe thod("POST");
servletConnecti on.setRequestPr operty("Content-type","applicat ion/octet-stream");
ObjectOutputStr eam outStream =
new ObjectOutputStr eam(servletConn ection.getOutpu tStream());
outStream.write Object(command) ;
outStream.flush ();
outStream.close ();
System.out.prin tln("MY RESULT IN APPLET");
InputStream instr = servletConnecti on.getInputStre am();
ObjectInputStre am inputFromServle t = new ObjectInputStre am(instr);
String result = (String) inputFromServle t.readObject();
inputFromServle t.close();
instr.close();
------------------------------------------------------------------
SERVLET CODE
--------------------------------------------------------------------
public void performTask(jav ax.servlet.http .HttpServletReq uest
request,javax.s ervlet.http.Htt pServletRespons e response)
{
response.setCon tentType("appli cation/vnd.ms-excel");
PrintWriter out = response.getWri ter();
String fileName = "temp" + Long.toString(S ystem.currentTi meMillis())
+ ".xls";
response.addHea der("Content-Disposition", "inline; filename=\"" +
fileName
+ "\"");
InputStream in = request.getInpu tStream();
ObjectInputStre am inputFromApplet = new ObjectInputStre am(in);
String command = (String) inputFromApplet .readObject();
String result = submitQuery(com mand);
System.out.prin tln("RESULT" + result);
out.println(com mand);
out.close();
--------------------------------------------------------------
java.io.StreamC orruptedExcepti on: invalid stream header
at java.io.ObjectI nputStream.read StreamHeader(Un known Source)
at java.io.ObjectI nputStream.<ini t>(Unknown Source)
at com.kbs.framewo rk.client.gui.P IPReport.doProc ess(PIPReport.j ava:562)
at com.kbs.framewo rk.client.gui.P IPReport.action Performed(PIPRe port.java:508)
at javax.swing.Abs tractButton.fir eActionPerforme d(Unknown Source)
at javax.swing.Abs tractButton$For wardActionEvent s.actionPerform ed(Unknown
Source)
at javax.swing.Def aultButtonModel .fireActionPerf ormed(Unknown Source)
at javax.swing.Def aultButtonModel .setPressed(Unk nown Source)
at javax.swing.pla f.basic.BasicBu ttonListener.mo useReleased(Unk nown
Source)
at java.awt.Compon ent.processMous eEvent(Unknown Source)
at java.awt.Compon ent.processEven t(Unknown Source)
at java.awt.Contai ner.processEven t(Unknown Source)
at java.awt.Compon ent.dispatchEve ntImpl(Unknown Source)
at java.awt.Contai ner.dispatchEve ntImpl(Unknown Source)
at java.awt.Compon ent.dispatchEve nt(Unknown Source)
at java.awt.Lightw eightDispatcher .retargetMouseE vent(Unknown Source)
at java.awt.Lightw eightDispatcher .processMouseEv ent(Unknown Source)
at java.awt.Lightw eightDispatcher .dispatchEvent( Unknown Source)
at java.awt.Contai ner.dispatchEve ntImpl(Unknown Source)
at java.awt.Compon ent.dispatchEve nt(Unknown Source)
at java.awt.EventQ ueue.dispatchEv ent(Unknown Source)
at java.awt.EventD ispatchThread.p umpOneEventForH ierarchy(Unknow n
Source)
at java.awt.EventD ispatchThread.p umpEventsForHie rarchy(Unknown Source)
at java.awt.EventD ispatchThread.p umpEvents(Unkno wn Source)
at java.awt.EventD ispatchThread.p umpEvents(Unkno wn Source)
at java.awt.EventD ispatchThread.r un(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.framewo rk.client.gui.R eportServlet");
HttpURLConnecti on servletConnecti on =
(HttpURLConnect ion)url.openCon nection();
servletConnecti on.setDoInput(t rue);
servletConnecti on.setDoOutput( true);
servletConnecti on.setUseCaches (false);
servletConnecti on.setDefaultUs eCaches(false);
servletConnecti on.setRequestMe thod("POST");
servletConnecti on.setRequestPr operty("Content-type","applicat ion/octet-stream");
ObjectOutputStr eam outStream =
new ObjectOutputStr eam(servletConn ection.getOutpu tStream());
outStream.write Object(command) ;
outStream.flush ();
outStream.close ();
System.out.prin tln("MY RESULT IN APPLET");
InputStream instr = servletConnecti on.getInputStre am();
ObjectInputStre am inputFromServle t = new ObjectInputStre am(instr);
String result = (String) inputFromServle t.readObject();
inputFromServle t.close();
instr.close();
------------------------------------------------------------------
SERVLET CODE
--------------------------------------------------------------------
public void performTask(jav ax.servlet.http .HttpServletReq uest
request,javax.s ervlet.http.Htt pServletRespons e response)
{
response.setCon tentType("appli cation/vnd.ms-excel");
PrintWriter out = response.getWri ter();
String fileName = "temp" + Long.toString(S ystem.currentTi meMillis())
+ ".xls";
response.addHea der("Content-Disposition", "inline; filename=\"" +
fileName
+ "\"");
InputStream in = request.getInpu tStream();
ObjectInputStre am inputFromApplet = new ObjectInputStre am(in);
String command = (String) inputFromApplet .readObject();
String result = submitQuery(com mand);
System.out.prin tln("RESULT" + result);
out.println(com mand);
out.close();
--------------------------------------------------------------
Comment