• Post Reply Bookmark Topic Watch Topic
  • New Topic

StreamCorruptedException

 
Rob McCarthy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having a problem when I try to connect to a servlet. I am using applet/servlet communication. The problem only occurs when I have lauched a crystal report via http in a new window.
After the report is launched if I try to hit my servlet I get the following error:
java.io.CorruptedStreamException: invalid stream header
Not all crystal reports I launch cause this behavior but I can see nothing in the url I use to launch the report that is out of place or different than other reports.
APPLET-SERVLET CONNECTION
try {
StringBuffer path = new StringBuffer();
path.append(ip);
path.append("servlet/DatabaseServlet?");
path.append("option=getRecords&query=").append(URLEncoder.encode(query,"UTF-8"));
URL url = new URL(path.toString());
URLConnection servletConnection = url.openConnection();
servletConnection.setUseCaches(false);
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
rc = (RecordCollection) inputFromServlet.readObject();
inputFromServlet.close();
} catch (Exception e) {
e.printStackTrace();
}
SERVLET CODE
*
Forwards to doPost
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("session id: " + request.getSession().getId());
this.doPost(request, response);
}
LAUNCHING REPORT FROM APPLET
try {
String launchURL = host + directory + report + "?promptOnRefresh=0"+ "&" +
authentication + "&" + key + "&" + startPeriods + "&" + reportYears + "&" + reportTitle + "&" +endPeriods + "&" + locations + "&" + reportPeriod + "&" + fiscalWeek + "&" + fiscalYear + "&" +time;
context.showDocument(new URL(launchURL), "_blank");
} catch (Exception ex) {
ex.printStackTrace();
}
SAMPLE URL THAT CAUSES PROBLEM
http://localhost:113/Reports/OpenToBuy_3.class?promptOnRefresh=0&user0=rpuser&password0=er34sw1&user0@sub1.rpt=rpuser&password0@sub1.rpt=er34sw1&user0@sub2=rpuser&password0@sub2.rpt=er34sw1&promptex-key="L","L1","ALL"&promptex-start="1"&promptex-years="2004","2004"&promptex-title="Report Title"&promptex-end="1"&promptex-locs="01","03","04","05"&promptex-period="Feb 2004 [04-01]"&promptex-cw="1"&promptex-cy="2004"&promptex-time=-2-52728"
Everything works fine until I launch this report then I can no longer get data from my servlet. I thought the URL lenght for the report might be the problem but I lauch a report with a URL longer than the problem one and there I don't get the errors after. When I try to connect to the servlet the println statement in the doGet method of my servlet doesn't get printed so it's not even making it inside that method in the servlet.
Anyone have any idea what could be causing this? Anyone have any ideas what would be causing this? I'm really stumped.
[ February 05, 2004: Message edited by: Rob McCarthy ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!