• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet getting Submitted Twice When I write in to Output Stream.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have one problem When I write byte[] in to output stream My servlet is getting submitted twice. Its getting in to doGet() method twice. If I comment os.write(pdf[i]);, Its getting submitted only once. Please help me.

Please see the code below.

private void outputPDF(HttpServletResponse response, byte[] pdf) throws IOException
{

response.setContentType("application/pdf");
log.debug("after getting into the response ");
response.setContentLength(getContentLen(pdf));
response.setDateHeader("Expires",0);
log.debug("after setting the content type and the date");

OutputStream os = response.getOutputStream();
log.debug("PDF Length Value=====" + pdf.length);

for(int i=0;i<pdf.length;i++) {
os.write(pdf[i]);
}
os.close();



}

Regards
Selvan
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I had an issue like this before when I was submitting a pdf object back to the client. It was due to a bug in the IE browser. It seem to be fix in IE 6.0 but then it got broke again. I would try using another browser (e.g.firefox) to see if it only submits it once.

The way we resolve it was to use a doPost instead of a doGet to retrieve the pdf object.

--Joe
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic