Content-Disposition inline/attachment

I am using Content-Disposition for excel file download as below:
I have searched the forum but not able to get the exact answer or solution. Please also guide me to some url if possible.
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename=xyz.xls" );
If I am using inline attribute but I am not able to specify the filename as xyz.xls and by default fileName provided by browser is the request URL(action-mapping in case of struts).
But it works fine with attachment attribute and prompts for the exact file Name and works fine.
I want to know how to specify the desired fileName with inline Attribute ? I am using the struts based request for Excel file generation.
Best Regards,
Amber Gupta

if You dont't mind , I just want to tell u something on this code.
If im wrong, Please tell me why? and what is the best way of acheiving it then,
the code below loads whole filedata and it does not matter how big the file is. Don't you think that it will heat up the memory by doing so. and consider the method what he was doing is perfectly right. but is there any other solution/wrong with above code what MR/ms/Mrs Kenneth has written like.
I just wanted to know the answer what is the wrong with MR. Kennth Code since i looked at it as a perfect working code(but with some glicth).
with Regards
Lokesh T.c
FileInputStream in = new FileInputStream(fileToDownload);
ServletOutputStream out = response.getOutputStream();
int bytesRead = 0;
byte byteArray[] = new byte[fileTODownload.length()];
// Read in bytes through file stream, and write out through servlet stream
/*while( ( bytesRead = in.read( byteArray ) ) != -1 ) {
out.write( byteArray, 0, bytesRead );
in.read(bytesArray,0,fileTODownload.length());
out.write(bytesArray,0,fileTODownload.length());
in.close();
out.flush();
out.close();

Similar Messages

  • EmailReceiver QPAC doesn't retrieve 'content-disposition: inline' attachments

    Hi,
    [Note: this is kind of a follow-up thread for
    Email receiver QPAC does not retrieve attachments other than .jar. Thought, I better post a new thread.]
    I experimented quite a lot with the Email Receiver QPAC. Regarding my testing, it seems as though it doesn't recognize attachments from emails, whose
    content-disposition is set to 'inline'. In fact, if I set the content-disposition to 'attachment', then the same attachment in the same Email sent via the same Email server is retrieved.
    Does anyone experienced this as well?
    Does the EmailReceiver QPAC actually retrieve 'content-disposition: inline' attachments?

    Hi Howard,
    thank you for providing the new version!
    We'll contact support then. Since some popular email clients like Thunderbird are set to 'content-disposition: inline' by default but we don't want our users having to adjust their client settings rather trickily, it's pretty important to us that the EmailReceiver actually handles inline attachments.
    Regards,
    Steve

  • 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

  • Error #2190: The attempted load of failed as it had a Content-Disposition of attachment set.

    I'm getting this error when I set the URL.
    Error #2190: The attempted load of  http://site.com/get_file_content.php?id=1000 failed as it had a Content-Disposition of attachment set.
    Is there a way to force the content type on the client?
    Here is the code I'm using:
                var resource:URLResource = new URLResource(path);;
                var element:SWFElement = new SWFElement(resource);
                mediaPlayer = new MediaPlayer();
                element.resource.mediaType = MediaType.SWF;
                mediaPlayer.media = element;
                mediaPlayer.addEventListener(MediaErrorEvent.MEDIA_ERROR, mediaErrorHandler);
                mediaPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, mediaPlayerStateChangeHandler);
                mediaPlayer.addEventListener(DisplayObjectEvent.DISPLAY_OBJECT_CHANGE, mediaPlayerDisplayObjectHandler, false, 0, true);
                protected function mediaPlayerDisplayObjectHandler(event:DisplayObjectEvent):void {
                    var displayObject:DisplayObject = event.newDisplayObject;
                    displayObject.width = 400;
                    displayObject.height = 250;
                    uicomponent.addChild(displayObject);
                protected function mediaErrorHandler(event:MediaErrorEvent):void {
                    trace(event.error.detail);
                    // Error #2190: The attempted load of  http://site.com/get_file_content.php?id=1000 failed as it had a Content-Disposition of attachment set.
    Message was edited by: thx1138

    The problem is that the server script is treating the request as a request for a file to download, rather than as a typical HTTP request/response.  You need to modify the server script so that it doesn't include the Content-Disposition header, there's not much you can do on the client side.

  • Missing "Content-Disposition" and attachment's file name

    We're testing OCFO 10.1.3.0.6 with MS Outlook 2003 and found some problems when message with attachments is received.
    If the attachment's file name is encoded and the body part looks like:
    Content-Type: application/msword; name="=?utf-8?B?encoded name?="
    Content-Disposition: attachment; filename="=?utf-8?B?encoded name?="
    everything is OK - the message is displayed as expected and the attachment's file name is decoded right.
    But, if Content-Disposition field is missing, the attachment's file name is not decoded - it's displayed as "=?utf-8?B?encoded name?=" (the name is obviously taken from Content-Type's name parameter), we loose information about file's type and we can't open the attachment.
    It seems that MS Outlook (without OCFO) is "smart" enough to decode Content-Type's name parameter as file name in the absence of Content-Disposition field. The same is true for Thunderbird.
    Any ideas?

    Actually the "name" parameter in Content-Type was declared depricated in RFC 1521 in september 1993, (now belongs to Content-Disposition) so they can be excused in a way....
    Message was edited by:
    user464123

  • 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.

  • Change content-disposition in email attachment

    I am using apex_mail (in Apex 4.1) to send emails with an attachment.
    v_mail_id := apex_mail.send(
             p_to  => '[email protected]'
             ...etc...
    apex_mail.add_attachment( p_mail_id    => v_mail_id
                             ,p_attachment => v_image
                             ,p_filename   => 'signature.jpg'
                             ,p_mime_type  => 'image/jpeg');
    Apex creates this as an attachment:
    Content-Disposition: attachment;
    I would like to change it to inline:
    Content-Disposition: inline;
    so I can reference it in my email body with <img src="cid:signature.jpg"/>. Well... I hope it is going to be shown inline anyway if I change Content-Disposition.
    Currently (with Content-Disposition: attachment;) it works for Outlook, but, for instance, not in Gmail in the browser. Gmail shows the image separately as an attachment.
    Is there a way to change the content-disposition with Apex?
    I know it is possible to do it with utl_mail, but this is currently not installed in our databases. I need to involve our DBA to set this up, and I don't know if he is willing to do that.

    Hi Joel,
    I thought so. I will put this in the Apex feature request database.
    Ino
    BTW, for other people it might be interesting to know that there is another option I tried that doesn't work in many situations either. You can put this in the email body:
    <img src="data:image/jpeg;base64,'||v_image_base64||'"/>
    where v_image_base64 is the base64 encoded jpg image.
    From my experiments the inline attachment with a cid reference seems to work best.

  • Download File by url in another server? (Content-Disposition","attachment)

    Can the file be downloaded by a url in another server?
    ie.
    Server A: JSP program
    Server B: filepath + filename = "http://xxx.com/xx/x.doc"
    e.g.
        response.setContentType("APPLICATION/OCTET-STREAM");
           response.setHeader("Content-disposition", "inline" );            
           response.setHeader("Content-Disposition","attachment; filename=\""+ fn.trim() + "\"");     
              java.io.FileInputStream fileInputStream =new java.io.FileInputStream(filepath+filename);
              int i;          
              while ((i=fileInputStream.read()) != -1) {
                      out.write(i);
              fileInputStream.close();
              out.close();     

    I tried this but it doesn't work. In the report column it shows up as Download" >_ .
    This seems to indicate that the href code is not being interpreted correctly.
    Following is exactly what I have in the URL field:
    <a href="#OWNER#.DOWNLOAD_MY_FILE?p_file=#NOTIFICATION_SEQ_ID#&v_type=SUMMARY">Download</a>Yes, I have granted execute rights to the procedure.
    Thanks,
    Dale

  • 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

  • Content-disposition header - office 2007 warning

    When I set the response header in the following way- using content-disposition inline- and try to open a xls file, I don't get the open/save dialog due to content-disposition but a warning message comes from office 2007 saying "The file you're trying to open is in a different format..."
    response.setHeader{"content-disposition","inline;filename="+filename}Whereas, for the response header set in this way- using content-disposition attachment- the open/save dialog appears without being followed by a warning from office 2007.
    response.setHeader{"content-disposition","attachment;filename="+filename}Is there anyway I can avoid open/save dialog due to content-disposition and still not get the warning from office 2007?
    Edited by: 1normalguy on Nov 18, 2008 10:54 PM

    The problem is that "xls" is a different format. Office 2007 uses xlsx because the format (for all Office documents) has been completely altered in Office 2007. They are no longer even close to being the same thing, anymore.
    Edit: Gods! So many typos in so small a text!

  • 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.

  • 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.

  • Download "Content-Disposition" to Excel

    I have a user who was having trouble getting an Excel file to download properly. When she clicked on the web link created by my procedure, her Excel file would download all the columns into one field. For myself, and most other users, it downloads normally with all the columns and fields where they should be. She was also missing the prompt asking if you wanted to open or save the file. It was just downloading to Excel right away.
    Now, the user said she did not have this problem with all her Excel downloads, just this one. So I looked at the program that had the Excel download that worked for her and compared it to the one that didn't.
    And there was a difference.
    The download that did NOT work for her had this line of code: htp.print('Content-Disposition: inline; filename='||v_file_name1);
    The download that DID work for her had this code: htp.print('Content-Disposition:attachment; filename='||v_file_name1);
    In the program that wasn't working for her I replaced the part of Content-Disposition with "attachment" instead of "inline". That seemed to do it. Nothing more needs to be done, but I dont' really know why it worked. I can't seem to find a definintion of what an "inline" Content-Disposition means vs. "attachment". Anyone know? Thanks!
    Oh, and here's the surrounding owa_util code in case that helps make it more clear where it was coming from:
    owa_util.MIME_HEADER('text/comma-delimited', FALSE);
    htp.print('Content-Disposition:attachment; filename='||v_file_name1);
    owa_util.HTTP_HEADER_CLOSE;
    Message was edited by:
    user527082

    I have a user who was having trouble getting an Excel file to download properly. When she clicked on the web link created by my procedure, her Excel file would download all the columns into one field. For myself, and most other users, it downloads normally with all the columns and fields where they should be. She was also missing the prompt asking if you wanted to open or save the file. It was just downloading to Excel right away.
    Now, the user said she did not have this problem with all her Excel downloads, just this one. So I looked at the program that had the Excel download that worked for her and compared it to the one that didn't.
    And there was a difference.
    The download that did NOT work for her had this line of code: htp.print('Content-Disposition: inline; filename='||v_file_name1);
    The download that DID work for her had this code: htp.print('Content-Disposition:attachment; filename='||v_file_name1);
    In the program that wasn't working for her I replaced the part of Content-Disposition with "attachment" instead of "inline". That seemed to do it. Nothing more needs to be done, but I dont' really know why it worked. I can't seem to find a definintion of what an "inline" Content-Disposition means vs. "attachment". Anyone know? Thanks!
    Oh, and here's the surrounding owa_util code in case that helps make it more clear where it was coming from:
    owa_util.MIME_HEADER('text/comma-delimited', FALSE);
    htp.print('Content-Disposition:attachment; filename='||v_file_name1);
    owa_util.HTTP_HEADER_CLOSE;
    Message was edited by:
    user527082

  • Convergence 2.1 displaying image attachments - honoring Content-Disposition

    Is it reasonable to assume that when displaying a message from within Convergence 2.1 that images (jpg for example) should be displayed based on the Content-Disposition header value? That is to say that if Content-Disposition is "inline" that the image shall be displayed in the body of the message and that if Content-Disposition is "attachment" the image shall not be visible until it is selected or some other action is taken?
    The behavior I observe in Convergence 2.1 is that inline images are show inline and are also duplicated again in a "preview mechanism" at the the end of the message. Attached images are not displayed inline but are also visible in the preview mechanism at the end of the image.
    Can this preview behavior be changed to explicitly honor Content-Disposition?
    From RFC 2183 (http://www.ietf.org/rfc/rfc2183.txt)
    2.1 The Inline Disposition Type
    A bodypart should be marked `inline' if it is intended to be
    displayed automatically upon display of the message. Inline
    bodyparts should be presented in the order in which they occur,
    subject to the normal semantics of multipart messages.
    2.2 The Attachment Disposition Type
    Bodyparts can be designated `attachment' to indicate that they are
    separate from the main body of the mail message, and that their
    display should not be automatic, but contingent upon some further
    action of the user. The MUA might instead present the user of a
    bitmap terminal with an iconic representation of the attachments, or,
    on character terminals, with a list of attachments from which the
    user could select for viewing or storage.

    Convergence 2-1.01
    Oracle Communications Messaging Exchange Server 7u4-21.01 64bit
    However this was determined to be a bug it is listed as having the ref # 12597156.. tho I have not seen any real movement on it in the SR I put in back in May.

  • Content-Disposition not working!

    Hi!, I've a servlet which its purpose is to read a file and write it later using a ServletOutputStream. This file must not be wrote as text, but instead the idea is to write it and then browser open it with a specific application. The extension of this file is already asssociated with the program that I want to use to open it. In fact, if I use a url link to the file, the browser requests the application and all goes fine, but I want that this application runs inside the browser, so I'm using content-disposition: inline; in order to do this, but I can't make it! The browser always try to download the file. My code is this:
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class imflpruebas extends HttpServlet{
         private ResultSet rs, rs2;
         private Connection connection;
         private Statement statement;
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              response.setHeader("Content-Disposition","inline");
              response.setContentType("application");
              String sFileName = "F:\\jakarta-tomcat-4.1.24\\webapps\\ImaxFileWeb\\temp\\reno_PRUEBA_0_0_0.IMX";
              File file = new File(sFileName);      
              byte[] byteContents = new byte[(int)file.length()];                
              FileInputStream in = new FileInputStream(sFileName);                
              int retcd = in.read(byteContents);                
              in.close();
              ServletOutputStream out = response.getOutputStream();
              out.write(byteContents);
              out.flush();
              out.close();
    }          I've tried to put the content type before the set header and the result is the same.
    Any ideas?
    Best whishes
    Raul          

    Hello Raul,
    There are a few things to consider. First of all, how do you want the browser to tell which application to use. Your content-type is very non-specific so the browser would never be able to tell by itself. Using a mime-type which has been mapped to an application might do a lot.
    Second, if you are using IE mime-types have little influence. IE tries to recognize the data by looking at the raw bytes and see if it recognizes the format. If not, IE will look at the URL and determine what to do with the data based on the URl extension. So if you have a link http://..../xxx.xls IE will try to show the data using Excel (if installed obviously). Adding such an extension (that can be ignored by the servlet) can do the trick with IE.
    If using IE check the Windows Explorer file settings (based on extensions). There is an "advanced" property called "confirm open before download" which should be cleared to allow an automatic open. Clearing the check "always ask before downloading" on the browser popup has no effect at all.
    Hope this helps.
    Regards,
    Silvio Bierman

Maybe you are looking for

  • No Photos on my iPhone since Update to iOS 5

    I made the Update to iTunes 10.5 on my Notebook with Windows XP and the Update to iOS 5 on my iPhone 3GS. I had a lot of Problems (the Backup had an Error, my outgoing Mails were all deleted in all Mail Accounts, the Synchronisation of Music and Apps

  • How do you delete the music off of the ipod nano

    I had transferred a copy of an album onto the nano and I can''t delete one of the copy. how do you delete on of the album.

  • Need help installing boot camp onto macbook pro

    I'm attempting to get Boot Camp to run on my MacBook Pro as I need to run several programs on windows for school. I purchased a Windows 8.1 download from Microsoft's website. The download from their website is not an ISO image and is not recognized b

  • I need to return my product

    My name is Valentina, I recently bought Adobe Photoshop Elements from this website and I do not need it anymore. I would like to return it, but I can´t find the solution...

  • Why won't Firefox let me register?

    All I wanted to know is how to get rid of the annoying ad for Mozilla Webmaker. The information offered by Mozilla support is an irrelevant remark, "First, please update to Firefox 31, 27 is no longer secure or supported. Update Firefox to the latest