I need assistance coding a servlet under WAS 2.02
Standard Edition, NT4.0 SP3 that sends a report in plain ASCII text
to a client browser and have the browser automatically fire up the
'Save As' dialog.
Thus far, I have succeeded to the extent that the client browser
opens the 'Save As' dialog and enables the end user to Save the file.
Unfortunately, a corruption in the communication between the client
and the servlet causes the servlet to resend the data.
Interestingly enough, this errant behavior is not displayed when the
the servlet runs under the JSDK2.0 servletrunner.
Here's what I have so far (apologies to Jason Hunter whose book
"Java Servlet Programming" - O'Reilly provided some of the code.)
ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
PrintWriter out3 = new PrintWriter(bytes,true);
// res is a reference to the HttpServletResponse obj
res.setContentType("application/x-MyApp-MyReport");
res.setHeader("Content-Transfer-Encoding","7bit");
res.setHeader("Content-Disposition","inline;filename=myreport.txt");
int size = 0;
String blankLine = new String(" ");
// vector records contains String objects
size = records.size();
out3.println(blankLine); //blank line
for (int i = 0; i < size; i++)
out3.println((String) records.elementAt(i) );
int buffSize = bytes.size();
System.out.println("sendReport buffer size = "+ buffSize);
res.setContentLength(buffSize);
bytes.writeTo(res.getOutputStream());
Thanks,
Craig Purpura
IBM Global Services, Dept T397
internet: [EMAIL PROTECTED]
Tie line: 532-8527
external: (914 ) 892-8527
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html