0

I am running into an issue opening a pdf/rtf link in our application. Ideally when the user clicks on the link the 'attachment' it should be rendered in a new tab in the browser. But in IE 10 it only renders gibberish. This is what we used and worked in IE 7 which we have been been using for a while.

<a href="<%=row.fileName%>" target="_blank">My_attachmentpdf</a> 

But when I opened some other pdf online in the same IE 10 it worked fine. I was thinking may be I should try to force it to save to disk locally as an alternative. Any thoughts?
PS: The application is j2ee web application and uses struts 1.0.
Thanks.

james2611nov
  • 473
  • 2
  • 10
  • 27
  • 1
    if you see `%PDF-1` at the start of the gibberish, then you're not sending out the appropriate mime headers and your pdf is being rendered as text/plain or text/html. – Marc B Sep 24 '15 at 21:46
  • so you don't have the right mime headers to tell IE you're sending a PDF, so it's defaulting to plain text. – Marc B Sep 24 '15 at 21:50
  • How do I do that in javascript? the `row.fileName` in the original post gives out `\myApp\myPdf1.pdf`. – james2611nov Sep 25 '15 at 13:40
  • there's nothing you can do in JS. it's something you have to fix on the server. – Marc B Sep 25 '15 at 15:57
  • @MarcB I think I should try something like this below. But I don't have the ServletResponse object. Is there another option I can try? [link](http://stackoverflow.com/questions/7386233/display-pdf-in-browser-using-java-servlet) – james2611nov Sep 28 '15 at 16:16

0 Answers0