am trying to stream a PDF doco to the browser via a servlet :
but in the browser it displays garbage characters !!
please advise what could be wrong.
forgot to say i am using I.E 6
Looks like your browser gets the data but it unaware about how to handle the data correctly. If the MIME type is set correctly, it would open as a PDF.
A fool proof method for this is to mention the content-disposition as an attachment, that way it will ask you how you want to use the file: open it or save it.
In case you want to directly open it in the window. use the disposition as inline instead of attachment. However for that make sure that the mime-type is set correctly.
prav ba wrote:but it still displays garbage characters e.g %PDF-1.4 %???܍ 4 0 obj <>>>>> endobj ......
Yep, that's what a PDF document looks like if you display it as text. So that's the problem, the browser doesn't know it's PDF. You appear to be setting the content type correctly so perhaps there's something else resetting it incorrectly later. Perhaps you have a filter which resets it to text/html for example. Look at the headers which the browser receives to find out what content type is actually being sent.
prav ba wrote:can you please point out how to look at the header which the IE browser receives in order to find out thet content type being sent to the browser??
No, I can't. I don't use IE for web development, I use Firefox. Which has the free Live HTTP Headers plugin for doing exactly that. One time when I was forced to use IE, I had to track down tools which cost $99 to do the same thing.