File download dialog box problem!

Hi,
How do you force file download message box to use specified file name instead of JSP or servlet name.
I am using:
// code in attachment.jsp
<%
response.setContentType(mimeType.trim());
response.setHeader("Content-Disposition","attachment;filename=\""+attachmentViewBean.getAttachmentName()+ "\"");
%>
With the above code, browser first pop up file download dialog box informing
'You are downloading the file:[attachment.jsp] from host. Would u like to open the file or save?'
I want the file name that I had specified in setHeader("Content-disposition","attachment;filename=resume.doc") to appear(i.e. resume.doc) in above dialog box and not the servlet name.
Any suggestions/tips on this?
Your help would be greatly appreciated.
Thanks,
Yogesh

For saving the document I have used -
res.setHeader("Content-disposition", "attachment; filename="+ FileName );
and it is working very fine, it saves the document with name specified in FileName
For opening the file in browser without any prompt-
res.setHeader("Content-disposition", "inline" );
For setting the content type -
try {
     if(FileType.equalsIgnoreCase("pdf")) contentType = "application/pdf";
     if(FileType.equalsIgnoreCase("doc")) contentType = "application/msword";
     if(FileType.equalsIgnoreCase("rtf")) contentType = "application/msword";
     if(FileType.equalsIgnoreCase("gif")) contentType = "image/gif";
     if(FileType.equalsIgnoreCase("jpg")) contentType = "image/jpeg";
     if(FileType.equalsIgnoreCase("html")) contentType = "text/html";
     if(FileType.equalsIgnoreCase("htm")) contentType = "text/html";
     if(contentType == null){
     contentType="text/plain";
     res.setContentType(contentType);
} catch (Exception e){
          out.println("Exception while setting content type");
          out.println("Exception : " + e);
          return;
Hope this helps

Similar Messages

  • Problem With File Download Dialog Box

    Hi all,
    I have jsp page that allows a user to export oracle data to excel.
    I have these code in my page:
    <%@ page contentType="application/vnd.ms-excel" %>
    response.setContentType ("application/vnd.ms-excel");
    response.setHeader ("Content Disposition",
    "filename=\"historicalrate.xls\"");
    I run the page and it popups a file download dialog box with Open and Save buttons.
    When I click the Save button a Save As window opens with a hr.xsl file name and Microsoft Excel Workbook(*.xls) as save type. It is what I want.
    The problem I have is when I click the Open button on the file download dialog box it displays data in excel format on a browser well. Then I click File > save as on browser's tool bar the Save As window pop up with no file name and a default Text(tab delimited)(*.txt).
    I need the file name and Microsoft Excel Workbook(*.xls) as default save type.
    Any help would be greatly appreciated.
    Please help
    Thanks

    I have the same problem with hui_ling.
    When user click on "Open", Excel start and open excel file correctly but the file name on excel title bar. 'Cause the file name is in Japanese characters. Any one can help me?
    Message was edited by:
    TNTVN

  • File Download Dialog Box

    Hi,
    I am creating a site using struts framework. In that one I code one "Download" hyperlink. Which should download Excel file to the client site.
    For this I want the Windows File Download Dialog Box to pop up when the user presses the "Download"
    hyperlink on the page. This is the dialog box which prompts the user to either open the file or save
    the file.
    However, instead of File download dialog box, IE opens the text document within itself.
    From what I understand, if the Mime Type of the file I am trying to open is registered on the client
    workstation, then this dialog box wont pop up as Windows would automatically get the registered Mime
    Type from the registry and open the application. For this we need to add headers to http response (content-disposition). Where to add this header info. In JSP, Action classes?
    Can somebody help.
    Thanks

    I am facing a similar problem...however in my case my application is on Tomcat server and when the user clicks the link, he/she sees junk data (excel sheet data) in plain html which makes no sense (with lot of special chars, just like opening any binary file in notepad)
    while if i run the application in WSAD then the links work fine....is there any difference in both the servers in the way they treat file download?

  • File download dialog box events and work around

    Hi all,
    I have a amall problem.
    when i set content type and header for downloading a file which is generated from the server i get a "file download dialog box" (open/save/cancel)
    but the problem is i cannot capture the events i.e. if the client clicks 'cancel' since i cannot capture 'cancel' i cannot do some other modifications that need to be done when the file is not downloaded.
    is there any way which i can track if the file is actully downloaded by the client or not??
    Or is there any way i can just by pass this dialog box and get a "save as dialog box" which enables him to choose a location directly download to his hard drive.(In this case i ll get a javascript confirmation before actully creating the file)
    i am using IE6SP1.
    Thanks in advance for your support.

    Just using JSP/HTML/Javascript code I don't think there is a way to do what you want. You might be able to do so using a Java Web Start application - like a download manager.

  • Change File Name In The "File Download" Dialog Box For Web Reports

    Hi All ,
    I followed the below note to change the "File Download" name.
    How To Change The File Name In The "File Download" Dialog Box For Web Reports? Doc ID: Note:418366.1
    However its not working. Has anyone tried this and works fine ?
    Basically I wanted to change the name "rwservlet" when a report is run in an
    excel format.
    Rajesh Alex
    Rajesh Alex

    Hello,
    Have you checked if a HTTP header "Content-disposition" is returned ?
    You can use ieHTTPHEaders for IE
    http://www.blunck.se/iehttpheaders/iehttpheaders.html
    and
    Live HTTP Headers for FireFox
    https://addons.mozilla.org/en-US/firefox/addon/3829
    Regards

  • File download dialog box -running report

    I am calling one report from my Oracle 9i Developer Suite Application. When i call one report using 'delimited' format, the run runs okay opening in a new Internet Explorer(IE) instance. But, when i call another report, the File download dialog box -running report opens which asks whether u want to open the file or save it in your computer. I hope, my doubt is clear.Please help me in this as it is very urgent.
    Regards.

    This is a duplicate post. Please followup on your previous posting.
    What is the URL you specify?

  • Urgent!!how to open the file download dialog box????

    Hi all,
    i'm using the browse button for the user to select the file
    and a submit button, which when cliked should open the file
    download dialog box asking for open or save.
    i searched for so many forums and websites and didn't get the
    solution yet.
    i'm using jsp.
    anyone have the jsp code for the same????
    will b more helpful if u send it to me.
    thanx in advance.

    Hi
    Use the Filedialog class.
    Let your button call a method wich contains the following Java code:
    FileDialog filedialog =
    new FileDialog( Frame1.this, "Open a File", FileDialog.LOAD );
    //witch calls this constructor: public FileDialog(Frame parent, String title, int mode)
    //use Filedialog.SAVE to save a file.
    filedialog.show();
    String filename = filedialog.getFile();//to display the name of the file
    String directoryname = filedialog.getDirectory();// to display the directory name

  • How to get file download dialog box in IE 6.0 for .CSV files?

    In our Java application, when we download .csv file (by clicking a tool bar button or menu item) in IE 5.5, it brings up the download dialog box and when we click the open button it opens the file in a seperate browser window but after migrating to IE 6.0 it doesn't bring the download dialog box and we are not able to open the excle sheet in a new browser window.
    We tried downloading .csv file in IE 6.0 by changing its extension(such as .cs1 and .xls) even then it did not work.We also tried associating CSV type of extension with "Microsoft Excel Comma Separated Values File" in the Windows folder options (Windows Explorer->tools->folder options->file types(tab)), which did not work.
    Please respond if you have come across this kind of issue and solution for the same.
    Thanks in Advance

    This has nothing to do with Java. It's Microsoft
    setting for known file type. IE is responding to the
    setting which will automatically download known file
    type (MIME type).
    To show the "Save As" file dialog, you have to do the
    following (for each file type)
    1. open Window Explorer
    2. click on Tool-->"Folder Option"
    3. click on the "File Type" tab
    4. select the extension and then click on the
    "Advance" button
    5. Check the "Confirm open after download" checkbox
    6. Click OK
    IE should now display the "Save As" file dialog for
    that extension. Remeber, you have to to this for all
    extension you want to see a "file dialog" pop up.Unfortunately this is not the only cause. Even with this box checked, downloading java source files from the pages of The Java Tutorial causes them to open in the most recent IE - I (and others also) don't get the save/open dialog box. Java source files downloaded from (some) other websites result in the save/open dialog box. I believe that one of the security changes that MS made in IE's handling of files is the cause. The setting of content-disposition by the server appears to be the key, according to MSDN information.

  • Wpg_docload not producing a file save dialog box

    Hi Everyone,
    I have a BLOB column in a database table and I want to show a link on a web page so when user click on it, it pops up a file download dialog box giving the user option to either open or "save as".
    I am using wpg_docload.download file but it seems to be load the blob data into the browser (inline)
    Here is the code:
       -- get image size
        intimgsize := dbms_lob.getlength(page_b_contents);
        -- print the header   
        owa_util.mime_header('Content-Type:application/vnd.ms-word;charset=utf-8', false);
        htp.p('Content-length: ' || intimgsize);
        htp.p('Content-Disposition:attachment filename="test.doc"');
        owa_util.http_header_close;
        -- download BLOB
        wpg_docload.download_file(page_b_contents);
    Any thoughts what might be wrong?
    Thanks

    How must wpg_docload.download_file hack across the network, and into the client o/s process executable running the browser, and then force that browser process to pop up a dialog box to save contents as a file?
    Do you understand the concept behind Mime types? The browser has specific actions (some configurable) for specific Mime types. PL/SQL can specify the Mime type. And provide a well formatted Mime header. It cannot however force the browser to act in a specific way when it receives that Mime stream from PL/SQL.
    See Office 2007 File Format MIME Types for HTTP Content Streaming - VSOfficeDeveloper: Known Problems, Bugs, and Fixes - Si… for basic header details.

  • Orarrp, IE file download dialog screen always asks before opening

    orarrp 1.3.4 working, but under IE5.5, the File Download dialog
    screen is activated when the web.show_document(<url>,'_BLANK')
    call is made, where the extension of the file is ".rrpa".
    The checkbox which reads "Always ask before opening this type of
    file" is checked and disabled. This means that user intervention
    is always required.
    When I open the .rrpa file directly in IE (the file is available
    on a locally attached drive -- that is, not as a URL at this
    point), IE opens and immediately prints the .rrpa file.
    Obviously the restrictions here are based on internet security
    settings, however, I've been unable to overcome this problem.
    There do not seem to be options in IE, nor in the
    characteristics of the file types themselves.
    Question: How do I set my environment to enable the "Always
    ask ...." check box, so it can be uncheck?

    I have no solution to my problem -- just more research results.
    From MS's support database, article Q232077, IE has a
    predefined, hard-coded list of file extensions that it
    inherently distrusts, which results in the "Always ask before
    opening" option to be checked and grayed out. The hard-coded
    list does NOT include orarrp extensions (such as .rrpa), but
    instead, extensions like .exe, .com, .bat, .cmd.
    Nonetheless, ".rrpa" is still seems to be treated as a
    permanently distrusted application -- I do not know why.
    To quote the aforementioned article: "[T]he File Download dialog
    box is not preventable in any way. This includes the use of HTML
    tags, script in the page, hosting the WebBrowser control, and
    changing security zone options."
    The article does go on to describe IE/Windows only solutions:
    <IFRAME> tag pointing to a shared Windows directory using MS's
    UNC; and ActiveX/cab construction and deployment. Clearly,
    neither is a solution.
    I can't quite conclude that there is no solution under IE, but
    its close.

  • Seeing multiple file download dialogs trying to download one file.

    I'm seeing some strange behavior from an application that uses the Safari Webkit to download a file from within the app. When I click the 'download' button I get cascading file download dialog boxes. Sometimes it is only two and sometimes it is 15+. Has anyone ever heard of this before????? Could it potentially be related to Java script or the version of Java?
    Thanks!

    Yes I've been in contact with the developer and they aren't sure what the issue could be as it seems to be happening for only a few users. From what they can tell it is only on Leopard. They use an SDK that calls into the Safari webkit, so they thought it might have something to do with my Safari preferences.

  • Modifying the name of the file in the download dialog box

    Hi all!
    I've a javascript page that make a pdf document in the fly and download that document. Everything is fine, but I'd like to know how can I modifying the file name in the download dialog box, i.e., when the page display:
    "You are downloading the file:
    xpto.jsp from ..."
    I want to substitute the "xpto.jsp" by "file.pdf".
    I've already theses lines:
    response.setContentType("Application/pdf");
    response.setHeader("Content-Disposition", "attachment; filename="+ nameFile+";");
    response.setHeader("Content-Length", ""+stp.length);
    but the problem persist.
    Note that in the second window, the Save As window, everything is fine, the nameFile appears in the file name box. The problem it's only in the first window, the File Download window.
    Thanks for any help,
    A. Santos

    I've discover something. When the File Download window it's displayed with the following text:
    "You are downloading the file:
    xpto.jsp from localhost
    Would you like to open the file or save it in your computer?
    button OPEN button SAVE button CANCEL button MORE INFO"
    if I press the OPEN button then another File Download window opens with the rigth text:
    "You are downloading the file:
    file.pdf from..."!!!
    i.e, the text desired!
    So the first window is unnecessary and undesired!
    How can I remove this first File Download window??
    Please help!
    A. Santos

  • 'Save Scanned File As' dialog box causing problems

    A lot of our users just upgraded to Adobe Std 8 from Adobe Std 7. With Adobe Std 8, the 'Save Scanned File As' dialog box comes up even before the document gets scanned (this was not the case with Adobe Std 7). How do you get rid of the dialog box? This is causing us a lot of problems because our Adobe is integrated with a document management program called DM5. With Adobe Standard 8 our users cannot save directly to DM5.Because the
    #Save Scanned File As# dialog box comes up first, now they have to tell Adobe to save it first somewhere other than DM, after the document
    gets scanned they save the document again to DM then they go back and delete the document that they saved in the other location. Is there a registry setting or anything that I can set to get rid of the 'Save Scanned File As' box. If you hit CANCEL, the document does not get scanned so users really do not have a choice but to save the document twice. As I said earlier, this was not the case with Adobe Std 7.

    Is there a registry setting or anything that I can set to get rid of the 'Save Scanned File As' box.
    No.

  • Problem with File Open Dialog box

    Gurus,
    I am using Forms 10g with Windows environment .. My requirement is, to display File Open Dialog Box, and whatever file I am selecting it has to open .. I am able to get Dialog box, problem is, when I select a file (for example, test.txt), I cant see the file getting opened .. Can anyone suggest me how to get the desired result ...
    Pasting my code below
    declare
         a varchar2(100);
    begin
         a := WEBUTIL_FILE.FILE_SELECTION_DIALOG('c:\temp','','*.*','c:\temp',OPEN_FILE, TRUE);
    end;
    Regards

    You can see the code in the webutil.pll library.
    FUNCTION CLIENT_GET_FILE_NAME (directory_name Varchar2 := NULL,
                                   file_name      Varchar2 := NULL,
                                   file_filter    Varchar2 := NULL,
                                   message        Varchar2 := NULL,
                                   dialog_type    Number   := OPEN_FILE,
                                   select_file    Boolean  := TRUE) return Varchar2 is                             
    * CLIENT_GET_FILE_NAME
    *   Client (Browser) side implementation of the standard GET_FILE_NAME Built-in
    *   Used to display File Open, Save  and directory listing dialogs
    *   Implemented using calls to WEBUTIL_FILE
    * Version 1.0.0
    * Change History
    *   1.0.0 DRMILLS 23/DEC/2002 - Creation
    \*********************************************************************************/ Here is one example:
    the_file := client_get_file_name('c:/', null, 'All Files (*.*)|*.*|',null,open_file,true);Francois

  • Problem in file download dialog

    Hi,
    I am using the following code to download a PDF file. (Whiich is present in the database and I am retriving it using JDBC call).
                        InputStream in = null;
                        HttpServletResponse response = ctx.response();
                        response.setContentType ("application/pdf");
                        response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
                        in = (InputStream)requestHandler.read(rparams);
                        byte[] buf = new byte[4096];
                        int len;
                        while((len = in.read(buf)) > 0)
                             out.write(buf, 0, len);
                        in.close();
                        out.flush();
                        out.close();                    
                        response.flushBuffer();
    Now when user is clicking on the specified link, file download dialog is coming, if user clicks on save the file is getting saved successfully but if user clicks on OK, it is giving the error, "There was an error opening this document. The file does not exist".
    Could anyone tell me what may be the problem in the code?
    Thanks in advance
    Amit

    Following code is returning the InputStream object:
         Blob document = null;
         QueryManager qm = null;
         int status = -1;
         InputStream dataStream = null;
         String sqlReadDocument = "select document from opr_t_aw_documents where id='"+id+"' and end_date > sysdate";
         log.debug("sqlReadDocument is "+sqlReadDocument);
              try
                   qm = new QueryManager();
                   ArrayList inParams = new ArrayList();
                   ResultSet result;
                   result = qm.performPrepQuery(sqlReadDocument, inParams);
                   if(result != null)
                        while(result.next())
                             document = result.getBlob(1);
                             if(document != null)
                                  dataStream = document.getBinaryStream();
    and out is simply response.getOutputStream().
    Please let me know in case you need any further info.
    Thanks,
    Amit

Maybe you are looking for

  • Preview fails to open PDF files in Safari

    Can anyone tell me why Preview will not now open PDFfiles inside Safari? I used to have Adobe PDF installed to open all PDF files but I have since removed it in preference to Preview. Preview opens all other PDF files just fine but it seems unable to

  • HT4759 my contacts are in windows mail, can I use this program in icloud

    I have just purchased an Ipad and would like to use Icloud to share my mail contacts with my Laptop, can I do this with Windows Mail?

  • Object link to STPO_DOC cannot be changed in this transaction

    Hi All, I am linking the BOM to Document info record, where I am getting a message as "Object link to STPO_DOC cannot be changed in this transaction". It is working in other way, when I go in BOM header and Link the Document, it is reflecting in the

  • Setting a Filter on a dynamically created Table

    Hi All, I am currently working on a Database to automatize some process. Quick explanation: The User can import a CSV (Text) File via a DialogBox, which gets imported into a Table. After this, the content has to be filtered, setting conditions on 4 d

  • ITunes Apple Script question

    Any thoughts why the following script generates will only force a refresh of the smart playlist "Random Country" if Live Updating is turned off. This script works for the other two playlists shown which have Live Updating turned on. on run