• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with opening a pdf in web browser

 
Michael Hul
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is where my question belongs but i'll give it a shot.

I need to display a pdf stored in a byte array in a web browser so this is what i've done so far. First i have a jsp that when submited executes the following:

Where 'OpenPDF' maps to my servlet. The problem is with the following code in the servlet:

The problem is that throws an IllegalStateExeption saying that 'OutPutStream already obtained' since the response being passed in is the response object from the jsp and it has that darn 'out' object.

What can I do about this so that I will be able to display the pdf??? Ideally in a separate window aswell.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to stream binary content, don't involve JSPs. That's causing the problem here. Craft the page flow so that the download request goes directly to the servlet that streams it. Then you should not have any problems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic