Want to force "Save As" dialogue

          Within a servlet, I have a byte[] containing data that I want to send to the user.
          I want to force the "save file as" dialogue box to appear, so I'm setting the
          content-type on the response to "application/octet-stream" and then writing to
          an OutputStream on the response. It's not working; can anyone help?
          (code snippet below)
          byte[] data = getTheData();
          res.setContentType("application/octet-stream");
          ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length);
          PrintWriter printOut = new PrintWriter(byteStream, true);
          res.setContentLength(data.length);
          ServletOutputStream out = res.getOutputStream();
          byteStream.writeTo(out);
          

Hi Laura,
          I can't tell what you are doing with all of those streams and writers. Try
          something like this (adjust content type as necessary):
          byte[] data = getTheData();
          res.setContentType("image/gif");
          res.setContentLength(data.length);
          ServletOutputStream out = res.getOutputStream();
          res.write(data);
          Note: To get the "image/gif" or "application/x-zip-compressed" or whatever,
          just look in Windows RegEdit in the HKEY_CLASSES_ROOT section under the .gif
          or .zip or whatever extension. It will show you the content type (mime).
          Note: The default file name can come from a special header or a meta tag,
          but the easiest way is to have the last part of the URL be the proposed file
          name; for example, the following will propose the file to be saved as
          "some.zip":
          http://www.myco.com/myapp/download/some.zip
          (Make sure that /download/* is mapped to your Servlet ... otherwise WebLogic
          will think it is a file request. Generally speaking, you want to completely
          turn off file service via WebLogic except for .gif and .jpg and .html
          maybe.)
          Peace,
          Cameron Purdy
          Tangosol Inc.
          Tangosol Coherence: Clustered Coherent Cache for J2EE
          Information at http://www.tangosol.com/
          "Laura Crook" <[email protected]> wrote in message
          news:[email protected]...
          >
          > Within a servlet, I have a byte[] containing data that I want to send to
          the user.
          > I want to force the "save file as" dialogue box to appear, so I'm setting
          the
          > content-type on the response to "application/octet-stream" and then
          writing to
          > an OutputStream on the response. It's not working; can anyone help?
          > (code snippet below)
          > -------------------
          > byte[] data = getTheData();
          > res.setContentType("application/octet-stream");
          > ByteArrayOutputStream byteStream = new ByteArrayOutputStream(data.length);
          > PrintWriter printOut = new PrintWriter(byteStream, true);
          > res.setContentLength(data.length);
          > ServletOutputStream out = res.getOutputStream();
          > byteStream.writeTo(out);
          

Similar Messages

  • How can I make the browser use the proper filename during a forced save, using CFCONTENT/CFHEADER

    We have a client using CF8 Server for a site and I am using the CFHEADER/CFCONTENT method to force a file to save to the end-user's computer.
    The dialogue comes up as expected, but regardless of what is found in the CFHEADER for a filename, it tries to save the file as the CFM page name.
    i.e. The CFM page is signature.cfm. I am trying to make it save a TXT file to the user's computer, which it seems to be trying to do, but the instead of using "sig.txt" as the filename as outlined in the CFHEADER, it is defaulting to "signature.cfm"
    While I know that I could change the name and extension and the content in the file would be correct, the mass majority of end-users will not know that they can do that, and the client does not want it to become more complicated than necessary.
    Is there a way to make the file change to the proper name in the SAVE AS dialogue?
    Thanks in advance.
    Code so far is pretty straight forward ...
    <CFHEADER name="Content-Disposition" value="attachment; filename=sig.txt">
    <CFCONTENT type="application/unknown" file="#xf#">

    I'm guessing the type="application/unknown" is interfering. Try type="text/plain".

  • Report opens Save as Dialogue Box, on client.

    Hi,
    I am using Report Builder 11.1.2.1.0, and I am calling a report from Form.
    If I run/call report on my own pc it opens perfectly in browser (pdf format), but if same report is opened on client pc, it opens Save As dialogue box and asks user to save the report.
    Can you please let me know, how can I achieve to open a report in browser on client's pc, without opening Save As Dialogue.
    Eagerly waiting for your replies.
    Regards,

    That is probably because the user's browser does not support opening a pdf document.
    Most browsers support pdf, some need a plugin. Check what happens with any other pdf document on the web that you want to open on the user's PC, like http://docs.oracle.com/cd/E16655_01/server.121/e17643.pdf

  • Finder changes the file name in Save/Save As dialogue box

    Whenever I save or save as a file, the dialogue box opens, but when I make the file list active when using a mouse, the file name I click to changes the file name I am saving. I simply want to activate the file list window so I can find the right folder. For example if I am looking for a folder called "Receipts" I want to be able to click on the file list window to activate it and then type the first 2 letters of the folder-- "re" and then save the file in that folder. The finder keeps changing the name of the current file whenever I click on one of the "greyed-out" file names? This doesn't make sense unless of course I want to replace that file.
    Is there a shortcut that makes the file list window in the dialogue box active while in the SAVE/SAVE AS dialogue box??

    Yes, this example of horrible UI design has been a problem since "Panther". It illustrates what happens when you try to copy UI behaviour from another OS, do it poorly, and end up with a mess. In 10.3 and 10.4, the combination of the renaming behaviour with the default "replace" selection in the resulting save can result in data loss.
    Compared to the old Mac OS where a tab would flip the focus between the text field for the file name and the file browser, the current behaviour either doesn't allow enough keyboard access to controls, or with "full access" enabled, too many to cycle through easily. The inability to switch focus to the file browser using the mouse (depending on the view) is a horrible productivity loss. Having to recheck the filename before saving is a horrible productivity loss. Since there is no "undo" for the renaming in most files, having to retype the name is again, a horrible productivity loss.
    If they had done it right (a simple change, like requiring a modifier to rename), users would probably welcome the "rename" feature as a useful addition. Instead, it has the feel of something a junior Windows-trained programmer slipped in past their supervisor.
    In short, I am not aware of any workaround or hack to avoid this "renaming" behaviour. I doubt it will do any good since people have been doing so since "Panther", but you could try submitting feedback:
    http://www.apple.com/feedback/macosx.html

  • Dynamically populate pdf File name in 'Save As' dialogue box

    We have  rendered a pdf using adobe webservice.
    Once the pdf is generated , and we click on saveAs menu dialogue box opens and default name is populated in fileName field.
    Can it be possible to populate that name dynamically ? We tried using response.addheader() but it didnt work.
    Note : We are using java to create xml which we are passing to adobe webservice.

    Hi Jaynet,
    In order to re-produce this, you need to answer "yes" to the rename file prompt and then continue with step 5 (above).
    The reason for this is not an exercise in futility - I assure you.  At my work and elsewhere, when web developers have created features to permit the end user to save web data in Excel format, often times the Excel files are saved locally in Excel's
    html format (but with the .xls
    extension). 
    (I actually prefer the .xls
    extension, because it is easier to just double-click the file to open in Excel, rather than to select the open-with and then select Excel. a file with the .html extension will default open in your default browser. Now, I could change my default program
    for the .html extension, but that would only solve a part of the problem and would not really address the bigger issue and that being that Microsoft changed a behavior in Excel and may not even be aware that it was a much used feature. )
    To continue, when I go to open the resulting Excel file, I am prompted with the message that the file type does not match the extension (which is fine and not bothersome to me).  It's at this point when I go to save the file that I get really annoyed.
    In previous versions of Excel, the default file name would be pre-filled with the current name of the file and the default file type would state that it is a Web html file.  I would just change the file type to Excel Workbook and hit enter to save.
    I would be prompted with "Are you sure you want to overwrite your existing file?" message and I would click "yes" and that would be that.
    However, in Excel 2010, because the default file name is blank, I then need to re-type the name into the field to save the file. 
    Any help is greatly appreciated.
    Thanks

  • In "save as"-dialogues, : (colon) turns into - (hyphen)?

    ahoi.
    in all "save as"-dialogues in os x 10.8, i cant use a : (colon) as character in the filename; instead it turns into a - (hyphen). is this wanted by apple? or am i the only one with this "problem"? i changed nothing in the settings...

    The colon is an illegal character in Mac filenames. This is a historical carry-over from the pre-Mac OS X days when the colon character was used as a delimiter in paths, instead of the slash ('/') that is used by the current Unix-based system.

  • How to realize the "save as" dialogue box?

    I want to realize this function in my jsp page:
    when I click a button, the system can prompt a new dialogue box which is the same as
    the "save as" dialogue box in windows 2000.
    How to realize it? Can I use JavaScript?

    You are asking about something that happens at the browser, so the question is identical to the one that asks how you can do it in HTML. But what do you expect to save with this dialogue box?

  • How to create my own Save As dialogue intead of using an auto pumped up one

    Our JSP web system allows our clients to be able to search data from the server-side database and then after get the resultset, they also should be able to save these data as a text file on their local machine by just a click. Of course, before they click the OK button, they should navigate the files system on their local machines and choose under which directory they want to put the file, and then provide a file name. I could NOT find a way to be able to navigate the local machine's drives.
    I know there is a standard Save As dialogue automatically launched by the browser. But my problem is: I don't need such a pumped-up Save As... dialogue which most brower will provide, because our system will have an interface which will provide the same function as the Save As guy. And this is the part that I am currently working on. Our interface will permit the client to browse their file system and then provide a filename, and then click OK to save the file. PLEASE, anybody who can help me. I know there are guys there have answers for my question.
    Can I use JFileChooser? Any better solutions?
    Thanks a lot.

    But also of course, you won't be able to use a JFileChooser in your JSP. As you said, you can't navigate the local system's drives. That's a deliberate design, for security reasons. Why do you want to waste your time replacing the browser's Save As dialog, which works perfectly well? You said "Of course, before they click the OK button, they should navigate the files system on their local machines and choose under which directory they want to put the file, and then provide a file name." That's exactly what Save As does.

  • Need server vm but don't want to force users to download JDK

    Hi,
    I need the numerical performance of the Windows 1.4.2 server vm for a 3D product I am working on, but don't want to force my users to download the entire JDK to get it. What is the official line regarding whether I can install just the server vm within their existing JRE? And can the vm be set within an applet?
    This of course also poses issues such as version control, both dealing with what is currently installed and now also dealing with auto-updates.
    I am currently paying a 325% performance penalty when using the client vm for numerical work!
    Andy.

    Hi,
    I need the numerical performance of the Windows 1.4.2
    server vm for a 3D product I am working on, but don't
    want to force my users to download the entire JDK to
    get it. What is the official line regarding whether I
    can install just the server vm within their existing
    JRE? No. Basically the entire JRE must be installed. There are certain parts that can be left out. You can check the readme for a list of those. I doubt it is going to save much.
    I could be mistaken but I also think you will find that getting the VM to run in server mode will also require a configuration change in the browser - and you are not going to be able to do that via a normal applet. And it will impact all java from that point on as well.

  • I installed 4.0 and cannot print anything. I uninstalled and installed 3.6 and cannot print anything. Everything has a .tif extension and wants me to save the file and I just want to print a selection from my email!

    I have had nothing but grief since I upgraded to 4. It is hateful. I can't print anything. If I highlight something from a website or my email and tell the printer to just print the selection, it doesn't print. It wants me to save the the file and they all have a .tif extension and nothing will print. I have uninstalled 4 and gone back to 3.6 and the problem is still there. If I highlight the desired selection and copy it to Word 2003, it will print what I want, but I can't print anything from the browser itself. That is the only problem I'm aware of so far. I upgraded about a week ago at most, maybe less than that. I'm so sorry I did. Why can't I print anything? I don't want my selection to be a file, I just want it to print!

    Thank you, but it didn't work. My printer stays on away, independently of the PC. I can print from Chrome and IE7 with no problem but not Firefox. The .tif extension refers to a tagged image something. I went looking around in the control panel and I found that Microsoft Office has it's own Access Snapshot Viewer. My company installed Office 2003 on my PC but I only use Word in my work. This snapshot viewer was listed in the control panel under Printers and Faxes. It was not the default anything but for some reason, Firefox 4 installation must have kicked it into gear. I've had the Office software for several months with not one problem. I have Firefox4 for less than a week and everything becomes difficult. I deleted the Office snapshot viewer (hope I don't get fired for it) so my little HP printer is the only one listed and now things seem to be working okay. I have FF 3.6 back up and running. I didn't lose any data and I hope the support and security updates stay available for a long time because it seems like there are plenty of people who aren't in love with FF4. Thank you so much anyway for your help.

  • Save Password Dialogue Box Not Displaying

    I am seeing behavior that suggests that the dialogue box for saving passwords is invisible:
    * I can frequently see the outline of a box where the dialogue box would be
    * On a couple of occassions, the dialogue box would appear for a few seconds before disappearing - I was once even able to save it
    * On sites where I enter a password, hyperlinks are not recognized in the area where the save password dialogue would normally appear - it's as if the window is there but not visible.
    I have uninstalled and reinstalled.
    Private Browsing is Off. Save passwords is checked.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    *Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Save As dialogue box and picking a folder to save the file in

    "If you have the destination folder open in the Finder, you don't have to navigate to it again in the Open or Save dialogs. Instead, you can just drag a file from the target folder in the Finder onto the Open or Save dialog box; doing so will instantly open that folder in the dialog."
    This was the old way... now it's gone... alongside skip while copying folder contents, regular expose for all open windows (not stupid mission control which put's all the windows from the same app in a group and I can't see the windows except the front one),....
    I hate Lion...
    any chance this can be sorted out? the save as dialogue drag&drop to pick a folder to save files in?

    You need to post this question to the Acrobat SDK Forum:  Acrobat SDK

  • Can we customize the Save As dialogue box in Acrobat DC?

    I was wondering if there is already a way we can customize the new DC Save As dialogue box.
    I would love to be able to open directly to "Choose a Different Folder" without going through this extra dialogue box (I understand the appeal of it, but it's not optimal for my workflow). Or perhaps, if I could customize the options under "Storage" (e.g. adding our own database folders "Posters", "Documents", etc, or maybe just pulling the "Favorites" folders from Windows explorer)
    I get the decision to have document cloud and creative cloud as default options. That's great for sharing and collaborating on documents, but I'm just managing too many documents and too large of a database. In my situation it's just, well, sub-optimal.
    I'm on Windows 7 running Adobe CC Group.

    OMG, I've been having this same exact thought since the first time I went to do a Save As ever since upgrading to Acrobat DC.
    (Mac OS X Yosemite here.)
    I find it so ridiculous to have to go through this extra step with every single "Save As."
    Example:
    1. Open our job ticket template PDF (for billing a project), which is in a "Company Templates" folder on my computer.
    2. Fill in the details/time for that project.
    3. Select "Save As" to save the job ticket to my project folder (different location).
    4. Have to click "Save to a different folder" every single time.
    "Save As" is nearly always going to be for saving a new version of a file to a different location, so I don't understand why there is now this extra step. It's just unnecessary IMO.
    So, to quote Will Riker: "Yes. Absolutely. I do indeed concur... wholeheartedly!"

  • PSE 7 is frozen with images in it - i dont want to force close and loose them - please help!!

    I load to iphot and transfer to PSE - my computer is very full and PSE has given me nothing but a colorwheel - i dont want to force close and lose what's in there  - please help me!!
    Thanks!!

    well, I can't answer questions about iPhoto, but either the photos are on your hard disk somewhere (in which case you won't lose them), or they are not on your hard disk somewhere (in which case I hope you have made recent backups).
    So which is it? Can you find the photos on your hard disk, or not?

  • Can't save a complete site in one go ? want to global save?

    Can't save a complete site in one go ? I want to global save? As a new site name... ta

    The site root folder name is not a part of the internal linking structure.
    Could you just rename the old local site root folder and delete the old site definition (ste and re-define the site under its new name?

Maybe you are looking for

  • Upgrading Mac Pro 3.1 (early 2008) worth it ?

    Hi I was wondering if it´s still worth to upgrade my mac pro 3.1 (early 2008) .....  or I should sell it and buy maybe the mac pro 2010 or anything like that... my system is 2,8 Ghz 8-Core 8 gb 800 Mhz DDR2 ram Ati radeon 2600 (i think it slows every

  • JSC doesn't show newly created extended DataProviders

    Hi, I've been using JSC and Hibernate for a project. According to Sun's how to using Hibernate + JSC (developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/hibernate.html) , I've created a wrapper class which extends ObjectListDataProv

  • "No brace at cursor to match" with MacOS X

    Hi there, I am having a problem with JDev code editor and MacOS X... it hapens in 9.0.3.x and 9.0.4. When trying to close braces [], I can never get the ] caracter as I always get the error "No brace at cursor to match". I am using spanish keyboard.

  • Webutil reattachment

    hi all, i have been using webutil for several weeks now. after getting everything configured almost everything works perfectly. the only remaining problem is that when i open a form in form builder and recompile it for the first time after rebooting

  • Oracle Upgrade 32 to 64 bit

    Hi all I need to upgrade Oracle DB from 32 to 64 bit. The OS is Solaris and SAP 4.5B. Can anyone guide me with URL's and Documents. I need the steps to be performed. Thanks.