To download file but still the Save Dialog box still not show? Please help.

Hi All,
Below is my full code to download file but still the Save Dialog box still not show..
<%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"
%><%@ taglib prefix="asset" uri="futuretense_cs/asset.tld"
%><%@ taglib prefix="assetset" uri="futuretense_cs/assetset.tld"
%><%@ taglib prefix="commercecontext" uri="futuretense_cs/commercecontext.tld"
%><%@ taglib prefix="ics" uri="futuretense_cs/ics.tld"
%><%@ taglib prefix="listobject" uri="futuretense_cs/listobject.tld"
%><%@ taglib prefix="render" uri="futuretense_cs/render.tld"
%><%@ taglib prefix="siteplan" uri="futuretense_cs/siteplan.tld"
%><%@ taglib prefix="searchstate" uri="futuretense_cs/searchstate.tld"
%><%@ taglib prefix="locale" uri="futuretense_cs/locale1.tld"
%><%@ taglib prefix="dateformat" uri="futuretense_cs/dateformat.tld"
%><%@ taglib prefix="blobservice" uri="futuretense_cs/blobservice.tld"
%><%@ taglib prefix="satellite" uri="futuretense_cs/satellite.tld"     
%><%@ taglib prefix="date" uri="futuretense_cs/date.tld"
%><%@ page import="COM.FutureTense.Interfaces.*,
COM.FutureTense.Util.ftMessage,
COM.FutureTense.Util.ftErrors"
%><%@ page import="COM.FutureTense.Interfaces.*,
COM.FutureTense.Util.ftMessage,
COM.FutureTense.Util.ftErrors"
%>
<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="java.io.File" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.FileInputStream" %>
<cs:ftcs><%-- france/test_template
INPUT
OUTPUT
--%>
<%-- Record dependencies for the Template --%>
<ics:if condition='<%=ics.GetVar("tid")!=null%>'><ics:then><render:logdep cid='<%=ics.GetVar("tid")%>' c="Template"/></ics:then></ics:if>
<%
String fileToFind = request.getParameter("file");
if(fileToFind == null) return;
File fname = new File(fileToFind);
System.out.println("Save As: "+fname.getName() );
if(!fname.exists()) return;
FileInputStream istr = null;
response.setContentType("application/octet-stream;charset=ISO-8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fname.getName() + "\";");
try {
istr = new FileInputStream(fname);
int curByte=-1;
while( (curByte=istr.read()) !=-1){
out.write(curByte);
out.flush();
} catch(Exception ex){
ex.printStackTrace(System.out);
} finally{
try {
if(istr!=null) istr.close();
} catch(Exception ex){
System.out.println("Major Error Releasing Streams: "+ex.toString());
try {
response.flushBuffer();
} catch(Exception ex){
System.out.println("Error flushing the Response: "+ex.toString());
%>
</cs:ftcs>
Can anybody help me with this??? What is lacking...
Thank you in advance.

Put this code into a servlet rather than a JSP.
JSP are for returning text based HTML pages. It adds extra carriage returns into the response that will corrupt the file, and prevent the dialog showing up.
This code is much better off being in a servlet
If you are using a FileInputStream, you should be using a ServletOutputStream rather than the JSP writer: response.getOutputStream()
When dealing with file input in a JSP/Servlet you should use the methods of ServletContext. getRealPath() turns a website relative file into a real location on disk. getResourceAsStream() opens the file for you. getResourceAsStream() is more reliable as it will work even if the web app is deployed in a packed WAR.
Cheers,
evnafets

Similar Messages

  • MS Word: This file is read-only. To save a copy, click OK, and give the document a new name in the save dialog box.

    This is not a question. I believe I've found a new issue and the fix for it.
    The situation:
    A brand new iMac 27" running Yosemite 10.10.1
    MacMini server running 10.8.5 server.
    The issue:
    Client on iMac trying to work on MS Word documents stored on server was requiring him to save the documents to his desktop and then copy them back to the folder on the server. The exact error message was, "This file is read-only. To save a copy, click OK, and give the document a new name in the save dialog box."
    The issue is unique to this computer in an office of 10 client computers and three servers.
    Attempted fixes:
    Verified that the ".Temporaryitems" folder existed and the permissions were set properly.
    Repaired permissions on the client and the network share.
    Definitive fix:
    By default, Yosemite 10.10.1 uses SMB for connecting file shares. When I overrode the default and switched to AFP protocol, the issue went away.
    I hope this helps someone else.
    Rob

    That was it. What an operating system. It is very helpful to view files you are looking for. But if you have preview on you cannot save files.

  • I am unable to save a keynote file as powerpoint. The 'save as' option is not showing in the files menu

    Hi, I downloaded the Keynote from the App store. I shoudl be able to save the presentation as a powerpoint, but the 'Save as" option is not showing in the file menu. Please help with a solution.

    Export
    If you are using Lion, there is no Save As in iWork apps. It is no longer a menu item.

  • MAC OSX 10.9.5: What is this strange file format in the Open Dialog box?

    Hello all.
    I'd never really noticed this, but I saw a rather unusual file format in the Open dialog box and was wondering why it appeared as it did. It appears as follows from the file/open dialog box:
    To be completely transparent, I'd originally posted this image on my twitter feed to @illustrator. Since then I have been in communication with Scott but the advice has been to reinstall Illustrator. If this had happened on one machine, I'd be inclined to agree that this may do something, but since discovering this unusual format, i've since seen it on six macs running OS 10.9.5 and illustrator version 18.1.0 OR 18.1.1
    Can anyone else confirm that they see the same thing; or if there is a difference, what this format is meant to actually be. I suspect this is a bug but need confirmation by other users.
    Colin

    The error occurs on all machines I have tested. 5 of the machines have the suitcase fusion auto-activation plug-in, but one had no plug-ins at all. All software was installed literally "out of the box" from the creative cloud.
    UPDATE - tested 3 more machines in the office all running 18.1.1 on OSX 10.9.5 and they ALL do the same thing, all installed with the suitcase fusion auto-activation plug-in, but otherwise installed "out of the box" from creative cloud.
    Colin

  • TS1363 My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue?

    My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue? I have already updated to the latest version of iTunes on my Windows 8 and I cannot synchronize my iPod for the time being. Please do help me to solve this problem. Thank You.

    uninstall all iTunes,5 programes,this worked for me after reinstall them

  • I have 4s iPhone , I download the iOS 7. Now the front receiver microphone is not working , please help me that how to fix the problem.

    I have 4s iPhone , I download the iOS 7. Now the front receiver microphone is not working , please help me that how to fix the problem.

    I live in South Africa, and I had the same problem with my iPhone 4.
    After weeks of frustration and swearing, I was in the process of restoring my phone to a previous iOS. To do that you need to turn the "Find my iPhone" option off, since i turned it off, my problem was solved. No need to repair anything or revert back to old iOS.
    ***** that i cant use Find my iPhone, but atleast i can use my phone.

  • HT4796 I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.

    I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.

    Send it as a PDF.

  • When I select a title or lower thirds and try to enter text by double clicking on it I cannot enter any text at all. Also the text area box does not show up at all where you can enter text also.

    When I select a title or lower thirds and try to enter text by double clicking on it I cannot enter any text at all. Also the text area box does not show up at all where you can enter text also.

    It's a bit hit and miss, Walter. Sometimes the box to enter text shows up straight away in the inspector under "text". Other times, although you click "text" in the inspector, there's nowhere to actually write anything.... then what you have to do is move the trackbar over the Title Box until you see the text boxes in the main Viewer. In the Viewer, double click a text box.... you can enter text there, but it's a bit flaky, but when you've clicked in it, you'll find that under "Text" in the inspector, the box for inputting text has magically appeared!
    I'm not sure if anyone else has this trouble, but it is a bit of a pain!

  • My iphone 5 is disabled and is not being read by itunes, itunes is giving me a prompt of my passcode, but that screen is not showing, please help me able my iphone.

    my iphone 5 is disabled and is not being read by itunes, itunes is giving me a prompt of my passcode, but that screen is not showing, please help me able my iphone.

    +Do a DFU recovery:+
    +1. Open iTunes.+
    +2. Connect the iPhone+
    +3 Press both the home and sleep/wake buttons until the Apple icon appears (ignore the red slider if it shows).+
    +4. Continue pressing the home button alone until iTunes sees your phone in recovery mode.+
    +5. Follow the prompts to restore the iPhone.+
    If not, take it down to mobile dealers that can reset your phone for you. All data will be lost.

  • The click at touchpad is not working, please help!!!

    I use Macpro, recently the click at touchpad is not working, please help!!! Thank you !!

    For this issue AppleCare support told me to so a SMC reset as follows:
    Power the machine OFF.
    At the SAME TIME hold down the following buttons:
    Shift
    Control
    Option
    Power
    Then release all buttons.  Power up the Macbook and see if the trackpad button work.
    Hope this helps.
    Bill

  • My iphone4 camera shutter not opening please help me to resolve this issue , i tried a restore it still exist, my iphone4 camera shutter not opening please help me to resolve this issue , i tried a restore it still exist

    my iphone4 camera shutter not opening please help me to resolve this issue , i tried a restore it still exist, my iphone4 camera shutter not opening please help me to resolve this issue , i tried a restore it still exist ,please help me

    uninstall all iTunes,5 programes,this worked for me after reinstall them

  • Clicking a .pdf link does not open .pdf file, it opens a SAVE DIALOG box

    Recently when I click on a .pdf file link I am no longer able to open the file in a adobe reader either within a FIREFOX webpage or open it using the full adobe program. Instead it opens a SAVE dialog box requesting me to save to my harddrive. I am not sure what has happened and am trying to find someone who might know what is going on?

    You can change the action for Portable Document Format (PDF) from Preview in Firefox to use the Adobe Reader or set to Always Ask in "Firefox > Options/Preferences > Applications".
    You can set the pdfjs.disabled pref to true on the <b>about:config</b> page to disable the build-in PDF viewer.
    You can check the value of the plugin.disable_full_page_plugin_for_types pref on the about:config page and remove the application/pdf part if present or reset the pref to the default via the right-click context menu.
    *http://kb.mozillazine.org/about:config
    See also:
    *https://support.mozilla.org/kb/view-pdf-files-firefox-without-downloading-them

  • HT1338 i try and download Aperture but i get a dialog box stating 'Aperture can't be installed on macintosh HD because OSX version 10.9 or later is required' i am using an iMac with OSX Mavericks

    I try and download Aperture but i get a dialog bos saying 'Aperture cannot be installed on macintosh HD because OSX 10.9 or later is required. I am using an imac with OSX Mavericks

    Welcome to Apple Support Communities
    Are you sure you are using OS X Mavericks? OS X Mavericks is 10.9, so it looks like you are using an older OS X version. To check this, open  > About this Mac, and check Version.
    To get Aperture from the Mac App Store, upgrade to OS X Mavericks. Open the Mac App Store and download OS X Mavericks. Make a backup of your files with Time Machine and check that your apps are compatible > http://www.roaringapps.com
    After upgrading, you will be able to purchase Aperture

  • Cannot stop "restore windows" dialog box from flashing. Please help!

    Finder not working! Bouncing finder icon and flashing 'restore windows' box are driving me slowly insane. I tried a few tricks like rebooting Lion 10.7.5 and deselecting "restore' in prefs but nothing has worked. Haven't found right terminal command yet either. I shut down my Mac with Safari open and maybe Google Chrome also, and when I turned it back on...my odyssey began. If you have ANY suggestions your help would be greatly appreciated.

    I got the same problem: I just purchased Office 13. When I tried to open a Word file that came viaOutlook I got the dialog box "Word can't open this file because a dialog box is open" but when I clicked further it opened the file OK and gave
    me the option to remove "Protected View" which I did and everything was OK. I called MS Support and the person who answered had a very thick accent that I could barely understand. When I told him my problem he did not understand it and said the program
    is trying to prevent me from opening viruses. I asked, why didn't it say instead of giving me the "open dialog box" error message? He had no answer and suggested I buy Microsoft support for $149 a year of $99 per incident. Great customer service,
    eh? Then I tried this solution by unchecking "Enable Protected View for Outlook Attachments" in the Trust Center and the Word files opened normally. I am very disappointed in Microsoft but thank Mike_obe for his excellent help
    Dave

  • After enabling the archivelog, DB control is not launching, please help

    I am using oracle 11G
    after enabling the archivelog, DB control is not launching, please help

    553ad454-5ce9-4515-bc7c-51c2e7fa3316 wrote:
    Thanks for your reply.
    I have enabled the Archivelog MODE for my database through DB control.
    after some time, DB control https://192.168.1.100:1158/em/console stops working & not opening.
    But I can able to loginto the sqlplus through command mode.
    please help
    Since you have used an IP in the EM's URL, there can be one more possibility besides this that the EM service has been stopped(as suggested by others already) . It may be a reason that EM  service is not up because the IP address has been changed due to a machine reboot. As 9/10 times, the IP addresses are assigned via DHCP  on home laptops and desktops, if this IP address is no longer there, the EM service won't be up. But before we shall come to know about this that whether this is indeed the reason, try the command-emctl status dbconsole and if it says, not running EM, emctl start dbconsole. Post the output of the commands.
    HTH
    Aman....

Maybe you are looking for