PDF content disposition on IE

Hi,
I am having difficulties in displaying PDF content from JSP. Obviously URL ends with mypdffile.jsp. From the JSP, I set attributes as follows. It works as intended on Firefox. Not on IE;
response.setContentType("application/pdf;charset=UTF-8");
response.setHeader("Content-Disposition", "inline;filename=\"Document.pdf\""); Any suggestions how I can fix this mess?

On IE, it shows nothing! I can see that it reads something then nothing shows up. It is meant to display inside the viewing frame without creating external frames. If I change to "Content-disposition: attachment; filename=ddd.pdf", it comes out with PDF view frame. If you move the frame, you see lots of dirty traces on Windows frame!
It may IE is not handling extension well.Or size information may be required.
JSP is convenient to write changeable reports. PDF is generated using iText.
Regards.

Similar Messages

  • Specifying pdf document's name in browser - content-disposition problem

    Hello ,
    I want to open a PDF document in browser, which needs to have a specified filename when user tries to save it.
    My web app sends an "application/pdf" document back to the browser.
    I use the Content-Disposition HTTP header to instruct the browser to open the document inline, i.e. using the appropriate plugin, which is Adobe PDF in this case. When the user clicks Save As..., the document filename needs to be the one specified by the same HTTP header. Here is the code:
    response.setContentType("application/pdf");
    String contentDisposition = "inline; filename=\"filename.pdf\"";
    response.setHeader ("Content-Disposition", contentDisposition);
    response.setHeader ("Content-Length",new Long(file.length()).toString());Unfortunately this does not work for me. Document opens fine, but I can't get it to have the name I specified. The plugin uses the default name, which is the full URL of the document. I tried several combinations of HTTP headers, but neither worked. I tried putting an additional GET request parameter at the end of the URL, like ...&filename=filename.pdf , but that didn't work either.
    I tried Adobe 7.0 and 8.1.2.
    Any suggestions ?
    Thanks a lot!

    Thank you very much for your answer.
    Needless to say I tried opening the document in IE, FF and Chrome, and neither worked.
    I had a look at the code at your web site, and saw that you were serving files for direct download: Content-Dispositoin:attachment... .
    This works fine for me too, and the filename is recognized correctly in that case. The problem is, I want to display the PDF inline...
    My server is not configured for URL rewriting, and I would be probably quite some problem to make this app work with it, so the /filename.pdf is not an option for me.
    Edited by: matavulj on Sep 25, 2008 7:21 AM

  • Content-Disposition in IE

    Hi
    I want to stream a pdf file and then show in the browser . res.setHeader("Content-Disposition", "inline;filename=temp.pdf;");
    This works with netscape but in IE it shows blank page after starting a Acrobat process.
    But if i use
    res.setHeader("Content-Disposition", "attachment;filename=temp.pdf;"); this works with IE and netscape both . I am not able to figureout what is the problem . Anyone knows solution for this problem ? Please let me know .
    Thanks in advance
    Amit Kumar

    Hi
    I want to stream a pdf file and then show in the
    he browser . res.setHeader("Content-Disposition",
    "inline;filename=temp.pdf;");
    Hi,
    I am currently working with reports being exported to excel
    You can try this :
    res.setContentType("application/pdf");
    I think it should work ....but I am not sure whether the mime type for pdf is ("application/pdf"); or ("application/vnd-pdf");
    try both ....let me noe if fit works ....:)
    cheers

  • Inline type of Content-Disposition problem in IE

    Hi,
    In a project, we need post some information from applet to servlet. The servlet will send some files back. We like the files shown on browsers. So we set the header in servlet as
    response.setHeader("Content-Disposition",
    "inline;filename=\"" + fileName + "\"");
    We use JSobject in applet to call form from a html file to post the information to servlet, target of the form is set as "_blank", which suppose will open a new browser and show the file. For example if the file is a word file, the IE will show the file inside browser.
    However, if two files need to be shown, only the first file is shown, the other browser is blank, and when you kill the blank window, the other will turn to blank window too. We test other types of file, xls files have similar problem, the PDF files work OK. Two things can fix the problem, one is set the form method to ��get��, the other is changing the header from ��inline�� to ��attachment��. But we can't use any of them under the project requirement. Has anyone experienced such wield behavior and know the reason? Is this the bug of IE?
    Thanks in advance!

    Here are a little more about the file types.
    The files we test have problems are msword or excel files, I think all MS office type files have the problem. Same problem even you mix them, for example one word file and one excel give you the same problem as two word files.
    However there is no problem if I view several PDF files. If we mix the word file with pdf file. If the first file to view is PDF, then it works OK. Otherwise same problem.
    The browser we are testing IE 6.0 with SP1.

  • Content-Disposition Convert to RTF

    Hi I have some problem with my jsp.
    Apprarently I am able to populate my page into MS-WORDS as RTF
    However I encounter Garbage value like
    &Amp; instead of &
    May there be some better way to convert? May it due to some settings i need to set on the response.XXX???
    Thanks for your help. Deeply appreciated.
    Derek Sum
    <%@ page language="java"%>
    <%@page import="test.kis.dto.*"%>
    <%@page import="test.kis.utility.*"%>
    <%@page import="java.util.*"%>
    <%@ taglib uri="/WEB-INF/struts-bean" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/standard/c.tld" prefix="c" %>
    <%
    response.setHeader ("Content-Disposition", "filename=appln.rtf;");
    response.setContentType("appln.rtf");
    java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("dd/MMM/yy");
    String today = format.format(new java.util.Date());
    %>

    To export PDF to RTF/Word file
    Using Adobe ReaderX or Reader XI
    Launch Adobe Reader X or Reader XI
    Select “Tools” and click “Sign In” link to sign in with your Adobe ID and password
    Select “Export PDF” then click “Select PDF file” link to choose your PDF file
    Select format from “Convert To” pull down menu(docx, doc,rtf,xlsx)
    Click “Convert”
    Click “Download Converted File” link to download the file to your computer after the process is completed.
    Using Web UI
    Log into https://createpdf.acrobat.com/signin.html with your Adobe ID and password
    Select “Export from PDF”
    Click “Select Files” button then choose your PDF file
    Select the format from the list below
    Check ON “Recognized text in” if your PDF file is scanned images to recognize the image to text
    Click “Export” button
    Click “Download” button in the progress bar after completion of exporting to download the file to your computer.
    Note: All exported files are stored at https//files.acrobat.com
    Hisami

  • Content-Disposition inline Not working

    Hi all,
    I am using Orion application server as Web server. I like to open a file in client side form the server. Which one is known MIME type. I don't want the IE to prompt the user for Save as/ Open from the current location.
    I am using "inline" argument in Content-Disposition header. Eventhough i am getting promt dialog box in client side.
    The following is my code.
    <%@ page import="java.io.*" %>
    <%@ page import="java.net.*" %>
    <% response.setContentType("application/pdf"); %>
    <% response.setHeader("Content-Disposition" , "inline;filename=test.pdf" ); %>
    <%
    String fileURL = "http://java1/examples/jsp/test.pdf";
         ServletOutputStream sout = response.getOutputStream ();
         URL url = new URL ( fileURL );
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
         try {
              URLConnection conn = url.openConnection();
              // Use Buffered Stream for reading/writing.
              bis = new BufferedInputStream(conn.getInputStream());
              bos = new BufferedOutputStream(sout);
              byte[] buff = new byte[2048];
              int bytesRead;
              // Simple read/write loop.
              while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                   bos.write(buff, 0, bytesRead);
         catch(Exception ex){
              System.out.println(ex.toString());
    %>
    Any one give the soloution for this problem. I hope there is no problem with the source code. I want to avoid the dialog box while downloading in the client side.
    Thanks
    Prabhu.

    Hi,
    Please let me know in which browser you are trying to do this, since it as some problem with IE5. You can try this, using the Netscape browser which doesn't have any problem.
    Hope this helps.
    Senthil Babu J

  • ParseException Content-Disposition filename spaces

    Hello All,
    I have an email generated from Thunderbird 1.5.0.9 (Windows/20061207) which contains an attachment whose filename has spaces.
    JavaMail (1.4) throws a javax.mail.internet.ParseException on the MimeBodyPart.getDisposition() call:
    javax.mail.internet.ParseException: Expected ';', got "-"
    javax.mail.internet.ParameterList.<init>(ParameterList.java:179)
    javax.mail.internet.ContentDisposition.<init>(ContentDisposition.java:87)
    javax.mail.internet.MimeBodyPart.getDisposition(MimeBodyPart.java:1039)
    javax.mail.internet.MimeBodyPart.getDisposition(MimeBodyPart.java:299) The offending attachment part has a part header which looks like this:
    Content-Disposition: inline;
         filename*0=Test - Test.pdf
    Clearly the parser is failing due to the spaces in the filename. Bugzilla for Thunderbird (Bug 221028 - https://bugzilla.mozilla.org/show_bug.cgi?id=221028) discusses this issue, however the status of the bug is VERIFIED WONTFIX.
    According to the Mozilla discussion, their implementation is conformant to the RFC:
    ...Just two days ago I was talking about this issue in #mozillazine with Christian
    Biesinger and Boris Zbarsky, and they said that this is the proper behaviour
    according to the RFC...
    Whether it IS conformant to all relevant RFCs I don't know, but it seems it won't be changed any time soon.
    This issue also exists for the Content-Type header in the same email which has the same format:
    Content-Type: application/pdf;
         name*0=Test - Test.pdfAnyone know if there is a way I can "safely" parse these headers? Is this a JavaMail bug?
    Thanks

    Absolutely, and please don't take my posting as a complaint - well over 99.9% of our emails are consumed flawlessly. I'm expressing more of (my opinion only) a high-level philosophical argument about of why I think good software (JavaMail) should try to by-default interact with not-so-good software. I'm not basing this not on "technical correctness", but rather the following unfortunate scenario:
    One particular example would be certain products made by a company with the initals "MS". These products almost always hide brokenness (they act as highly liberal consumers). Outlook, Internet Explorer, are the 2 primary examples. So a user (and unfortunately most users have never read or care about an RFC) opens the email with Outlook, or the web page with Explorer, etc. It "works". Now, we programmers certainly know better, but remember that we aren't buying or choosing products or services, we're offering them. User then opens with Java-based product (stack trace). User buys or chooses MS-based product, MS-based product retains market stranglehold, commercial email providers test their products with Outlook, and in the end, brokenness is propagated anyway. It's kind of like reverse-Darwinism for software (survival of the most-broken).
    Some customers complain that JavaMail doesn't strictly enforce every requirement of the standards
    As an SMTP producer, I might see that, but personally I can never recall seeing a single problem with outgoing email from JavaMail. As a client consumer, I'm not sure why they would take that philosophy, unless maybe they are using JavaMail to test RFC-compliance.
    there are forms of brokenness that go beyond what can be handled at the JavaMail API level.
    Of course, but I have yet to see a message that the "MS" client could not read. So perhaps they are working around some of these at a higher level (in the GUI, maybe?)
    But for developers who don't think about this problem...
    Most developers most likely aren't using JavaMail to read in over 25,000 emails a day. So admittedly, I'm in a unique situation.
    Having made that decision it's relatively straightforward to configure JavaMail appropriately. Not really, one change required updating the jar file, others require obscure uses of the API. And a developer/administrator is only going to make those changes after seeing the problem.
    to avoid propagating brokenness as you suggest.
    Brokenness will get propagated anyway (see reverse-Darwinism, or the Theory of De-evolution above).
    I'm looking forward to trying out 1.4.1, and thanks again for all the assistance, a very thorough FAQ, and overall a great API. I think the opensourcing was a good idea, JavaMail really is by far the best API that I have seen for this type of high-volume work.

  • Making pdf content downloadable via link in Iview problem

    Hi,
    I have been having problems with the following scripting code, where I have a link that when clicked makes a PDF file stored in the KM downloadable to the users local area.The file does download to the users desktop but when opened, the content is corrupt. So when a user clicks the view link the PDF document is loaded into the browser iframe with no issues. However when they click the download link they get the attached error.The file can be viewed properly through an  iframe in an iview on the portal but when downloaded via this script 'token missing' errors occur.
    I have pasted the code and would appreciate any help offered.
    Thanks
    Rebecca
    pResponse.write("<a onClick=\"blur(); downloadDoc('" + fileIds<i> +  "'); return false;\" href=\"javascript: void(0);\">");
                                       pResponse.write("<img src=\"" + docURL + downloadGif + "\" border=0 width=\"16\" height=\"20\" alt=\"Download\"></a></td>");
                                       pResponse.write("</tr>");
                             pResponse.write("</table>");
    Generate the link to use for file downloads
                             IPortalComponentURI componentURI = pRequest.createPortalComponentURI();
                             componentURI.setContextName(downloadPCDPath);
                             String uri = componentURI.toString();
                             pResponse.write("<script>");
                             pResponse.write("function downloadDoc(docToDownload)");
                             pResponse.write("{");
                             pResponse.write("document.getElementById('downprint').src = '" + componentURI.toString() + "?rid=' + docToDownload; ");
                             pResponse.write("}");
                             pResponse.write("</script>");
                             pResponse.write("<script><!--\n");
                             pResponse.write("function changeURL(newurl) {\n");
                             pResponse.write("this.location.href = newurl;\n");
                             pResponse.write("}\n");
                             pResponse.write("//--></script>");
                             pResponse.write("<iframe name=\"downprint\" src=\"\" style=\"width: 0; height: 0;\"></iframe>");
                        } //end if
                   printStyle(pResponse);
              } catch (AccessDeniedException ex) {
                   ex.printStackTrace();
                   mDbUtil.writeException(ex, pResponse );
              } catch (ResourceException ex) {
                   ex.printStackTrace();
                   mDbUtil.writeException(ex, pResponse );
              } catch(Exception ex) {     
                   ex.printStackTrace();
                   mDbUtil.writeException(ex, pResponse );

    I am not quite sure what this is supposed to be doing, however, a better method would be to have a custom component which accepts a RID to a resource. This component would then read the content of the PDF (using its bytes) and write these bytes out to the HttpServletResponse output stream. You need to make sure that the HTTP header content-disposition is also set correctly (can't remember exactly what this should be, however, a quick google search should return the correct results).
    This should be all you need to do I believe. Let me know if you need any help with this further
    D

  • Firefox is stumbling when pages with PDF content come up. how can i get my old version3.5.6 back?

    Question
    firefox is stumbling when pages with PDF content come up. how can i get my old version3.5.6 back?

    Thanks for your response Cor el, I'll try that the next time it happens, it's completely random. One moment it functions normally then suddenly it changes its mind.
    Restarting my pc usually brings it back to normal until next time.
    One thing I've noticed, but not 100% sure there's a connection here.....I edit my websites online and log into cpanel which opens new pages in separate tabs, as it should do. It seems that this problem occurs when I'm logged into cpanel...if i'm logged in then open a new tab for regular browsing of other sites then all links on those sites also open in new tabs.
    Ican't say for sure if it's always only happened when logged into cpanel, but certainly on the last 3 occasions.
    At the moment it's behaving normally so much I can do to check your suggestions, but will try them the next time it occurs.
    One other thing I forgot to mention too....since i've had the new firefox, I've noticed that when I log into yahoo and post comments, I often find myself having to log on for each new post. Everything was fine with old firefox and there have been no other changes to my pc .

  • How to specify the charatcer encoding for the parametes Content-Disposition

    I want to download a file with chinese name .
    response.setHeader("Content-Disposition","attachment; filename=" + fileName);
    the above part of code is working fine for english file names. but i am facing problem when i try to get file with chinese name .
    The pop up window is not defaulting with the chinese name .
    When i searched for net , in one rfc it was specified how to do that one.
    http://www.faqs.org/rfcs/rfc2184.html.
    I tried it but .. could not able to solve the problem.

    Hi,
    Am facing similar problem with russian and japanese characters in file name.
    I tried the UrlEncoder.encode(filename, "utf-8') api to encode the file name. This worked fine with IE but firefox and safari shows junk for japanese/russian characters.
    Anyone having an idea abt this?
    Thanks,
    Kapil

  • Setting the title for File download dialog when using content-disposition

    I am trying to send a file from server to client (browser). I am setting the content type of the resopnse and using the "content-disposition" header and giving the filename.
    But the issue is, when it is downloading and the dialog box is showing the progress bar, The title of the dialog box is showing something like "40% of localhost:9080.....". It doesn't show the file name in the title bar. Also, if the URL is very long (I am passing some get parameters and the servlet name is also long), I get junk characters like small boxes.
    How to set this title in the servlet?

    Is there a reason why you have to use FileReference.Save versus File.browseForSave?  In Adobe AIR, the File class, which extends the FileReference class,    provides more capabilities and has less security restrictions than the FileReference class.  Using File.browseForSave, it has a title:String parameter which is a string that is diplayed in the title bar of the dialog box.

  • Problem with non-ASCII file name in content disposition header

    Hi All,
    I am facing some problems with the non-ASCII file name incase of content-disposition header. I read from the RFC 2183 that if the file name contains non-ASCII characters then the same should be encoded before sending to browser. I did the same but realized 2 problems:
    1. The name of the file is truncated in case the file name is slightly long for e.g. �����������j�b�g��������������������������.txt
    2. Also when the same file is opened in notepad, the title is showing encoded name %E6%9C%80%E4%B8%8A%E4%BD%8D.....
    Overall, I feel that the browser is not understanding or responding to the encoded header values.
    Is there any solution to this problem? I am using Microsoft IE 6.0.
    The code snippet is given below:
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              String fileName = "�����������j�b�g��������������������������.txt";          
              fileName = URLEncoder.encode(fileName, "UTF-8");
              resp.setCharacterEncoding("UTF-8");
              resp.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
              resp.setContentType("application/download-binary");
              String s = "This is inside txt file";
              resp.getOutputStream().write(s.getBytes("UTF-8"));
              return;
         }Any help or pointer would be highly appreciated.
    Thanks and Regards,
    Ashish

    The MIME standards for non-ASCII filenames are not widely implemented.
    Many mailers use an ad hoc method for encoding filenames. JavaMail
    supports both methods, but you need to set properties, such as the
    mail.mime.encodefilename property. See the JavaMail javadocs for
    the javax.mail.internet package.

  • "This is an Adobe Illustrator file that was save without PDf content."

    I have a client that has been working on a file in AI CS, never left his machine, but when he went to open it today he gets a message that says this file "was generated by a newer version of Illustrator. Would you like to import this file? Some data loss may occur".
    And when we click the "Import" button, we then get:
    "This is an Adobe® Illustrator® file that was saved without PDF content. To place or open this file in other applications, it should be re-saved from Adobe Illustrator with the "Create PDF Compatible File" options turned on. This option is in the Illustrator Native Format Options dialog box, which appears when saving an Adobe Illustrator file using the Save As command."
    However, even though this was created in AI CS, all other machine and all other versions of AI (even CS3, 3.3, 2, etc..) we get the same exact error message. How it can be newer than CS 3.3 when it was created in CS is strange to begin with.
    I assume this is some sort of corruption, but was wondering if there were any cures. It seems our backups have backed up this file in it's current state (corrupt), which is a huge issue at this point.
    Thank you very much for any help!

    I have sometimes had this trouble since I updated Acrobat.
    "This is an Adobe® Illustrator® file that was saved without PDF content ..."
    Not sure what's wrong - it seems to happen even though the Illy file is saved with PDF content and everything embedded.
    Another thing: When viewing pdfs under Advanced>Print Production>Output Preview I repeatedly get an RGB simulation preview even though I know that the file is CMYK. So I have to choose a CMYK simulation preview and then things look o.k.
    Is there any way to stop the RGB preview coming up? I note that Convert Colours messes things up completely, so it's only the preview that's wrong.
    Any ideas, Wade?

  • Bug: DocumentManager does not emit Content-Disposition header

    Good afternoon,
    I have a process with an output variable of type Document: this document has a defined filename. When invoking the process, instead of downloading the file with the defined filename, I was receiving a file with a name that looks like an MD5 hash.
    The fault for this lies with the DocumentManager application: it does not emit the content disposition header that would suggest to the browser what the real name of the octet-stream is. As such, without this header, the user agent will assume that the file-name is the endpoint name.
    The trace of the HTTP exchange is below:
    GET http://HOST:8080/rest/services/APP/SERVICE:1.0?q=83
    Cache-Control     no-cache, must-revalidate
    Date              Wed, 17 Nov 2010 12:54:29 GMT
    Pragma            no-cache
    Transfer-Encoding chunked
    Location          http://HOST:8080/DocumentManager/docm$(NUMBER)/$(HASH)?type=$(TYPE)
    X-Powered-By      Servlet/2.5 JSP/2.1
    GET http://HOST:8080/DocumentManager/docm$(NUMBER)/$(HASH)?type=$(TYPE)
    Date              Wed, 17 Nov 2010 12:54:35 GMT
    Transfer-Encoding chunked
    Content-Type      application/vnd.ms-excel
    X-Powered-By      Servlet/2.5 JSP/2.1
    The 2nd HTTP request should have included the specified header, like so:
    Content-Disposition: attachment; filename=MyExcel.xls
    RFC 2183: The Content-Disposition Header Field
    Best regards,

    Hi Robert,
    thanks for the reply. This is certainly a different aspect of the problem. The HTTP response that serves the dynamic portion (the one with the timestamp) has the response headers:
    HTTP/1.1 200 OK
    Date: Wed, 21 Jan 2015 18:05:53 GMT
    Server: Apache/2.2.29 (Unix)
    X-Powered-By: PHP/5.3.29
    Cache-Control: max-age=100000, public
    Keep-Alive: timeout=3, max=95
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: application/xml
    So it is marked as cacheable. 
    My expectation now is this:
    - when clicking the "refresh" link in the markup, there should be no new timestamp. Reason is that the dynamic part should have been cached and I would expect the XSLT engine to use the browser's caching layer when fetching fragments
    - when hitting "F5" I would expect a revalidation request to be send to the server (e.g. max-age=0 or if-modified-since). Then the server can revalidate the fragment. In my example case the fragment would be served in any case, so I would expect a
    new timestamp
    - when hitting "CTRL+F5" I would expect a request with "cache-control: no-cache" that enforces the server side caches to always return new content. I would expect a new timestamp in this case.
    What I observe is that:
    - Chrome and FF work as expected
    - IE (10/11) will always fetch the dynamic fragment, so I will even see a new timestamp when clicking the refresh link. Also the "if-none-match" header in the "F5" case is NOT forwarded to the dynamic fragment (potentially because it is
    not cached in the browser at all)
    Carsten

  • Upload file - get rid of Content-Disposition: form-data;

    Hello,there.I just want to know if somebody had succesfully solved problem of getting rid of rows
    at uploaded file
    -----------------------------7d23c05be8
    Content-Disposition: form-data; name="fromflr"; filename="C:\WINDOWS\Desktop\Clock"
    Content-Type: text/plain
    "Some Data"
    -----------------------------7d23c05be8
    Content-Disposition: form-data; name="toflr"
    HARGAL
    I just need get rid of rows like
    -----------------------------7d23c05be8
    Content-Disposition: form-data; name="toflr"
    HARGAL
    and leave only "Some Data" in uploaded file.
    Any suggestion would be appreciate.

    See for example Upload taglib from Coldtags suite:
    http://www.servletsuite.com/jsp.htm

Maybe you are looking for