Set filename for file download

Hi
i have a servlet that sends a file to the client to be downloaded. When the client requests the file the dowload dialogue pops asking if the user wants to download/open but the name of the file is always the servlet name were it originates. Is there any way to set the filename and extension in the servlet e.g ExampleResult1234.csv and send this to the client so that when the dialogue pops up it is set?
Current Servlet Code:
String output = "some data from database in csv format";
        response.setContentType("application/binary");
     response.getWriter().write(output);Thanks
David

It would be nice for the next person who needs help with this if you posted your solutions. :)

Similar Messages

  • Any way to set up iWeb pages for file download / sharing?

    I have been using .Mac Homepage to set up several web pages to share audio files with my clients. I have been able to set up a different web page for each client, each with their own password, with files there for them to download.
    Is there a way to duplicate this using iWeb now that .mac homepage sites are going away? I don't want the audio to stream, I just want to make the files available for downloading, and don't see any page templates in iWeb '08 for file downloading.
    I know that I can use mobileme's new file sharing feature to email links to individual files, but this doesn't work as well as having all the files downloadable on one or more web pages.

    If you have all of the sites in one domain file you should be able to upload only the changed pages but it's been a while since I used 08 so don't remember. You can move each site into its own domain file so that only that site is edited and published. And if you're publishing directly to mobile me only the edited files should be uploaded.
    I use iWebSites to manage over 75 individual sites.. It lets me create multiple sites and multiple domain files.
    If you have multiple sites in one domain file here's the workflow I used to split them into individual site files with iWebSites. Be sure to make a backup copy of your original Domain.sites files before starting the splitting process and move it to another location on your HD until you're satisfied the separation process is completed and what you want.
    This lets me edit several sites and only republish the one I want. Make sure you're running the lastest version of iWeb, 2.0.4 I believe.
    An example of files set up for immediate download is Toad's Cellar. Each linked is linked to a zipped file which downloads when clicked on. The site could be password protected if so desired.
    OT

  • Drop-down Menu to Open URL for File Download

    I am using Adobe Captivate 5.5 and was wondering if it is possible to create a drop-down menu that can be used to open different URLs for file downloads, kind of like the Attachments button Presenter has. Captivate seems to have a dropdown widget available but I can't tell if this would work for this purpose.

    Hi Theo
    You can use any composition to create a menu with setting for show target on rollover and then link targets to specific pages.
    Adobe Muse CC 7.0 Tutorial | Beautiful Graphic Navigation - YouTube
    Thanks,
    Sanjit

  • JSF error message: Automatic prompting for file download

    This is a weird problem. I have a JSF application wherin I popup a new window on a submit button.
    The window opens a test.jsf page that redirects the output to a servlet1.
    Servlet then based on some parameters does a sendRedirectI() to different servlets out of context.
    Now the issue is that when the output is redirected to out of context servlet, that returns a file download.
    If in IE browser, if one does not do a setting of "Automatic prompting for file download", this window that I had opened on submit buttton vanishes in a jiffy. If the IE setting is done, it shows the file download correctly.
    I would want to show the user some kind of message by which he/she understands that this IE setting has to be done.
    I have tried several ways:
    1. Javascript: window.onbeforeunload on the test.jsf so that when the window unloads i can show some message. But since test.jsf forwards to servlet1, the html page generated does not show my script.
    2. I also tried checking if some windows registry can help me understand the setting.
    3. I tried writing in response object the javascript and then redirecting it to servlet out of context. But I guess sendRedirect() does a new request, so this did not help.
    Can anyone help? I am not sure if I am able to explain my problem correctly.
    Yani

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • Automatic prompting for file download

    I am using a File Download Servlet. Theres a setting in IE under Securiy Settings --> Downloads--->Automatic Prompting for File Downloads.If I have this disabled, I am able to download the file.If its enabled, I am unable to download the file successfully. Anyone have faced this problem before?

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • Adding a new layout for DME for file download

    Hi All,
    How do i add a new layout for file download in DME?
    Thanks
    William Wilstroth

    This problem is solved.
    Need to enhanced the T042O table.

  • I install IDES 4.7 in VMware, Why "unable to set time for file...."

    system     Windows2003
    database   Oracle 9
    disk space : C(50G)D(80G)E(40G)
    "Copying file C:/DOCUME1/ADMINI1/LOCALS~1/Temp/SAPinst/bootstrap_keydb.1.xml to: C:/SAPinst ORACLE SAPINST.
    INFO 2014-01-26 16:22:47
    Copying file C:/DOCUME1/ADMINI1/LOCALS~1/Temp/SAPinst/bootstrap_keydb.xml to: C:/SAPinst ORACLE SAPINST.
    INFO 2014-01-26 16:22:47
    Copying file C:/DOCUME1/ADMINI1/LOCALS~1/Temp/SAPinst/CONTROL.DTD to: C:/SAPinst ORACLE SAPINST.
    ERROR 2014-01-26 16:22:47
    FSL-02010  Unable to set time for file C:/SAPinst ORACLE SAPINST/CONTROL.DTD.
    ERROR 2014-01-26 16:22:47
    FJS-00012  Error when executing script."
    who can help me ..please.....

    Hello Matthew,
    You should also change your temp directory to something woth no spaces, something like C:\temp.
    Sapisnt sometimes has problems with the spaces in the temp path, and the Universal Installer nearly always
    has a problem with this.
    Regards,
    David

  • Pcmanfm can't set programs for file types

    I would like set a gpicview for jpg files, but when I set this program in pcmanfm menu - pcmanfm doesn't open jpg with gpicview...
    after installing thunar - I set gpicview for jpg in thunar and now pcmanfm is opening jpg with gpicview...
    How change this strange problem? Why thunar is able to set programs for files but pcmanfm doesn't?
    Last edited by william7 (2008-07-19 20:38:19)

    .oO(teachAA)
    >I'm embedding numerous audio files in Dreamweaver CS3
    using the <embed> tag.
    >I'm using CSS to control the box size and other
    attributes relating to how the
    >file displays on the page, but I'd also like to set the
    parameter "autoplay" to
    >false, and controller to "true," for all of the audio
    files. I've been doing
    >this individually for each file (very time consuming),
    Search & replace exists.
    >because I can't figure
    >out a way to do it with CSS. Is there a way to set those
    parameters in CSS and
    >apply it to all files?
    No. CSS is for presentation, but these parameters belong to
    the HTML and
    have to be written there.
    BTW: The 'embed' element is invalid HTML. If you care about
    valid markup
    and your site doesn't have to be compatible with really old
    browsers
    like NN 4 or IE 5.5, then you should use the valid method
    using 'object'
    elements.
    Micha

  • Java WebDynpro's and IE security settings for file download

    We have a EP 7.0 SP13 environment on which we have deployed a number of own developed java webdynpro's. In some of these webdynpro's we provide the file download functionality. The portal and webdynpro's are used by both internal personnel and external customers.
    On the other hand the default Internet security settings for Internet Explorer, disable "Automatic prompting for file downloads".
    When a user, with these default security settings active, tries to use our webdynpro's file download functionality, the screen seems to refreshes but no file download starts. When (s)he retries, the session runs for some minutes and gives following error message:
    "com.sap.tc.webdynpro.services.session.LockException: Thread SAPEngine_Application_Thread[impl:3]_20 failed to acquire exclusive lock on client session ClientSession".
    This behavior is explained in SAPNote 1234847. Webdynpro provides a single-thread module, meaning a user session is blocked for the during of the request. And because the previous file download isn't yet completed the new try can't start.
    Issue now, although the users IE settings allow file downloads and don't block pop up's, he can't download the file and even isn't made aware of the cause of the failure.
    How can we avoid this issue, without having to communicate the
    application requires specific browser settings?

    Welcome to the Apple Support Communities
    See > http://support.apple.com/kb/HT5290
    You can install the program using different ways:
    1. Right-click the application installer and choose Open.
    2. Go to System Preferences > Security and Privacy and select Anywhere in Allow applications downloaded from

  • Problems with signed Applet for File Download under JRE 1.4 (works with 1.3

    Dear all,
    i encountered a very strange behaviour with JRE 1.4x. A signed applet used for file download worked on all platforms (Windows NT, 2000 and XP wth/wthout SP...) until I installed JRE 1.4.x (1.4.1 or 1.4.2)
    I get an EOFException when downloading binary files (for ASCII it works fine) when trying to readByte() from a DataInputStream. But not immideately, but after x bytes in the while-loop. Security is fine (I know there have been changes to that in jre 1.4, the applet itself can be started an runs with ASCII files for transfer)
    Does anyone know, what has changed in jre1.4.
    As I said, it works fine under jre 1.3.x
    The relevant code is below: byte bt = dis.readByte(); causes the error
    try{
    // Get URL from Server
    URL uFile = new URL(sFilename);
    sThisURLFile = uFile.getFile();
    Integer inte = new Integer(i);
    //open input stream for the file on server
    DataInputStream dis = new DataInputStream(new BufferedInputStream
    (uFile.openConnection().getInputStream()));
    //open output stream for the file on local drive
    String sFilenameOnly = sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1);
    int iDotPos = sFilenameOnly.lastIndexOf(".");
    String sExt;
    if (iDotPos > 0) {
    sExt= sFilenameOnly.substring(iDotPos);
    } else {
    sExt = "";
    File fileOut = new File(sDownloadDir + sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1) );
    DataOutputStream dos = new DataOutputStream(new
    BufferedOutputStream(new FileOutputStream(fileOut)));
    //read one byte from input stream, and write that byte to output stream
    long nByte = 0;
    int iCnt = 0;
    iFilesizeDone ++;
    while (nByte < iFilesize){
    String sErrPs = new String();
    try{
    sErrPs = "00";
    byte bt = dis.readByte();
    sErrPs = "01";
    dos.writeByte(bt);
    } catch (EOFException ee)
    System.err.println("internal EOFException: " + ee.getMessage());
    System.out.println("Error Filesize is " nByte " of " iFilesize "---" + sErrPs);
    break;
    nByte++;
    iFilesizeDone ++;
    iCnt ++;
    if(iCnt >= 10240) {
    ShowProgress(nByte, iFilesize, iFilesizeDone, iFilesizeTotal); // repaint does not work during init-procedure
    iCnt = 0;
    line = "Progress: Total: " + ((iFilesizeDone*100)/iFilesizeTotal) + " perc, " + iFilesizeTotal/1024 +" kbytes" ;
    labLine.setText(line);
    //dos.flush(); // improves Client performance (Agent-Call!)
    dis.close();
    dos.close();
    }// End try
    catch (EOFException ee)
    System.err.println("EOFException: " + ee.getMessage()e);
    catch (SecurityException se)
    System.err.println("SecurityException: " + se.getMessage());
    catch (IOException ioe)
    System.err.println("IOException: " + ioe.getMessage());

    perhaps they've changed something with the file blocking.
    btw, you should try to use something like this
    DataInputStream dis = new DataInputStream(is);
    byte[] buffer=new byte[8192];
    int numBytesRead;
    while ( dis.available()>0 ) {
         numBytesRead = dis.read(buffer);
    }               

  • Peformance Turning for File Download / Upload with Enabled SharePoint Audit

    Greetings all, may I ask your help for Peformance Issues?
    Background:
    I tried to create a ASP.NET Web Page to download/upload/list SharePoint file and deployed to IIS website in same application server (will NOT use web part as some users are NOT allowed to direct access confidential workspace)
    Besides, for Audit Log record purpose, the page will impersonate (without password) the logged in user:
    SPUserToken userToken = web.AllUsers[user].UserToken;
    SPSite s = new SPSite(siteStr, userToken);
    For File Listing, the web service can provide fast response, and we are using service A/C for connection (as no auting for listing, but require audit for file download upload)
    Several implemeation options tested for File Downloiad / Upload, but issues occured and finding listed below:
    Issues
    1) SharePoint Object Model
    When I open Site (using new SPSite), it's too slow to respond. (under 1s for all operations, but require 10~50s for open SPSIte. e.g.
    using(SPSite s = new SPSite(siteStr) //50s
    How can I download/upload file without open SPSite object (using SharePoint object model, but user token should be kept to allow SHarePoint identifiy user actions. e.g. Updated by Tom, NOT system administrator)?
    2) SharePoint default web service
    For file download, I tried to use SharePoint Web Service for download file, it's quick but how can SharePoint record the audit log to downloaded user, and not service A/C? ( e.g. View by Tom, NOT system administrator)
    With Windows SSO solution, please note system should NOT prompt to ask user password for use impersonation
    3) HTTP Request API (for file download)
    As mentioned in point 2, if the system cannot get password from user, SharePoint also recorded service A/C in audit log... ><
    Thank you for your kine attention.
    .NET Beginner 3.5

    Thank you for prompt response, please find my reply with Underline:
    Hi,
    Maybe I'm not quite clear about the architecture you have now.
    Is your asp.net application deployed in separate IIS site but in the same physical server as SharePoint?
    Yes
    "we are using service A/C for connection", can you please explain the 'A/C'?
    Domain User, Local Admin and also SharePoint Service Admin A/C
    Opening SPSite is relatively slower but shouldn't take 50 sec. However it depends on your server hardware configuration. You should meet the minimum hardware requirements for SharePoint.
    Assigned double resources based on minimum hardware requirements.
    For details, 50s is the load test result. But for other SharePoint operation, it takes around/under 3s reponse time.
    Are you using SharePoint Audit log? Exactly If so then why don't you just put the hyperlink to the documents in your asp.net page. User maybe have to login once in SharePoint site but
    it depends on your security architecture. For example if both of your sites in local intranet and you are using windows integrated authentication, SSO will work automatically  User is NOT allowed
    to access SharePoint site/server (not implemented for sepreate server yet, as performance issues occured for
    separate site in same server)  directly from Internet, the
    middle server with web interface created for user request.
    Whatever I understands gives me the feeling that you download the file using HTTPWebRequest C# class. However regarding security it depends on how authentication is setup in asp.net web site and in sharepoint. If both site uses windows integrated security
    and they are in the same server, you can use the following code snippet:
    using (WebClient webClient = new WebClient())
    webClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
    webClient.DownloadFile("file ur in sharepoint", "download directory");
    Thanks, will try and reply later
    But still, as I've mentioned, not quite clear about the whole architecture.
    A) Request Handling
    1) User use browser to request file listing and/or download file (hereafter called: File Download Request) from custom ASP.NET page (Let's say In Server 1, IIS 1)
    2) ASP.NET page  or File Handler ashx (Server 1, IIS 1) call custom web service, SharePoint deault/OOTB web service or using SharePoint Object Model to access SharePoint Document Library (in Server 1,
    IIS 2)
    3) Both SharePoint and IIS Web Site
    (Server 1, IIS 1 & IIS2) using the same service A/C
    4) The web service , File Handler return file obeject to IIS1
    5) IIS 1 reply File Download Request to user
    B) Application Architecture (In testing environment)
    1) no load balancing
    2) 1 DB server (Server 2)
    3) 1 Application Server (with IIS 1 - ASP.NET, IIS 2, SharePoint Web Site with default SharePoint Web Service, IIS 3 SharePoint Admin Site & IIS 4 Custom SharePoint Web Service)
    4) Sepreate AD Server (Server 3)
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com
    .NET Beginner 3.5

  • KM Document iView for file download - filename

    Hello,
    we have a hyperlink on our portal logon page for downloading a word document. This link points to a KM document iView. The iView has the property "Path to Document" set to the document in the KM.
    By clicking the link, a file download pop-up appears. But the filename of the downloadable file is the path of the iView - and not the real name of the document.
    Is there any possibility to get the real name as name for the downloadable file? Or should we use another iView?
    Any hint is appreciated!
    Best regards,
    Matthias

    Sorry Tom!
    Your problem seems to be different, I've no idea.
    But we already fixed our problem, I forgot to post. Here's our solution:
    The solution was to create a KM Docs iView with anonymous authentication schema pointing to the download file. Then we created an URL iView pointing to this KM Doc with appending the filename AGAIN to the URL (because otherwise the iView ID will appear as filename). In the page a hyperlink now is pointing to the URL iView and after clicking it, the download starts with the correct filename.

  • Filename on file download from jsp

     

    This may help:
              ----- Original Message -----
              From: "Erik Lindquist" <[email protected]>
              Newsgroups: weblogic.developer.interest.jsp
              Sent: Wednesday, June 28, 2000 6:20 PM
              Subject: How to dynamically display images in JSPs
              > This took a little while to figure out so I thought I'd share. After
              > doing some research I was led to the following approach on how to load
              > images from an Oracle database into a JSP:
              >
              > The "main" JSP:
              >
              > <HTML>
              > <head>
              > <title>Image Test</title>
              > </head>
              > <body>
              > <center>
              > hello
              > <P>
              > <img border=0 src="getImage.jsp?filename=2cents.GIF">
              > <P>
              > <img border=0 src="getImage.jsp?filename=dollar.gif">
              > <P>
              > world
              > </body>
              > </HTML>
              >
              >
              > And this is the image getter:
              >
              > <% try {
              > response.setContentType("image/gif");
              > String filename = (String) request.getParameter("filename");
              > java.sql.Connection conn =
              > java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              > connect to db
              > java.sql.Statement stmt = conn.createStatement();
              > String sql = "select image from testimage where filename = '" +
              > filename + "'";
              > java.sql.ResultSet rs = stmt.executeQuery(sql);
              > if (rs.next()) {
              > byte [] image = rs.getBytes(1);
              > java.io.OutputStream os = response.getOutputStream();
              > os.write(image);
              > os.flush();
              > os.close();
              > }
              > conn.close();
              > }
              > catch (Exception x) { System.out.println(x); }
              > %>
              >
              >
              > The thing to note is that there are no <%@ page import="..." %> or <%@
              > page contentType="..." %> tags - just the single scriptlet. It
              > seems that for every "<%@" the weblogic compiler sees it puts
              > out.print("\r\n"); statements in the generated java source.(???) I
              > don't know much about how browsers work but I think that once it sees
              > flat ascii come at it it treats everything that follows as text/plain
              > which is incorrect for the binary stream that's being sent. Another
              > work around was to set out = null; but that's kind of ugly and might
              > produce server errors. The real fix is to write a bean to handle images
              > which I'll work on next (does anybody have any hints on how to do
              > that?)
              Cameron Purdy
              [email protected]
              http://www.tangosol.com
              WebLogic Consulting Available
              "Ramesh" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi,
              >
              > Even I could download the files with this technique, I couldn't open the
              file downloaded. It seems the file is getting currepted during tranfer.. Can
              u help me in this regard please?
              >
              > Thank u
              > Ramesh
              >
              > [email protected] (Anders B. Jensen) wrote:
              > >In an Web-application written in Java Server Pages it should be possible
              > >for the user to download data from the web-server. The data will never
              > >exist as a file on the web-server, only in the PrintWriter object, out.
              > >To force the Internet Explorer (IE) to show the download dialog window
              > >the Contenttype of the HTTP-header have been set to "html/transfer". The
              > >question is:
              > >
              > >Is it possible to set the filename appearing in the download dialog
              > >appearing on the client?
              > >
              > >
              > >Below is a listing of the source-code:
              > >
              > ><%@ page extends="com.beasys.portal.admin.PortalJspBase"%>
              > ><jsp:useBean id="download" scope="session" class="dk.lec.DownloadData" />
              > >
              > ><%
              > > String tmpstr;
              > > response.setContentType("html/transfer");
              > > out.clear();
              > > tmpstr=download.getStrbuffer().toString();
              > > out.println(tmpstr.trim());
              > >%>
              > >
              > >
              > >Anders B. Jensen
              > >Consultant, Research & Development
              > >LEC AS
              > >
              > >Remove the SPAMLESS to mail me.
              >
              

  • To display non US-ASCII filename in file download dialog - Help Needed

    Hi,
    Our application supports to upload a file with name in chinese/japanese language. When user tries to download filedownload dialog box is appearing with the filename as junk characters.
    How to solve this issue to display the filename as uploaded.
    Thanks in advance
    ~kans

    bsampieri, issue is in display of the file name in
    file download dialog.
    ~kansI understood that, but my thought was that the HTTP headers content type containing a charset of UTF-8 might help. I don't know for sure, but otherwise, I don't know how to get the browser to otherwise not assume ASCII.

  • Implementing file "Save as" functionality for file download api

    Hi,
    I want to implement File Download (Open/Save as/Cancel dialogue box) programmatically.
    I am displaying list of links to document in a web dynpro table and I dont want to set IWDResource data for all entries in table.
    And on Click of a button/link to action, I want to open up a File download box.
    I have URL to the file with me and I'm able to convert it to IWDResource.
    Following are the things available with me for a selected file:-
    -- Complete name of file along with extension
    -- byte[] of file.
    Please help.
    Thanks and regards,
    Amey Mogare

    I could achieve it with following code:-
         String l_str_LinkValue = null;
         String l_str_LinkName = null;
         URL l_url = null;
         InputStream  l_is_inputS = null;
         try {
              l_str_LinkValue = wdContext.currentCtx_vn_KmFolderDataElement().getLinkValue();
              l_str_LinkName = wdContext.currentCtx_vn_KmFolderDataElement().getLinkName();
              l_url = new URL(l_str_LinkValue);
              l_is_inputS = l_url.openStream(); 
              IWDResource res = WDResourceFactory.createResource(l_is_inputS, l_str_LinkName, WDWebResourceType.UNKNOWN, true);
              if(res != null){
                   wdContext.currentContextElement().setFileRes(res);
              }else{
                   myMessage.reportException("Unable to create file", true);
         catch (MalformedURLException mfurle) {
              myMessage.reportException("MalformedURLException : "+mfurle.toString(), true);
              wdContext.currentContextElement().setFileRes(null);
         catch (IOException ioe) {
              myMessage.reportException("IOException : "+ioe.toString(), true);
              wdContext.currentContextElement().setFileRes(null);
         catch (Exception e) {
              myMessage.reportException("Exception : "+e.toString(), true);
              wdContext.currentContextElement().setFileRes(null);

Maybe you are looking for

  • Inbound queue error

    Hi Gurus, I am facing a problem with inbound RFC Queue,error message is logical system not defined in table smof_erpsh. i hav e cheked the table but not too sure about how to activate the queue. please help. Regards, Samarjit

  • Casting c to string in a methode calling

    Hallo, I've a methode with a string paramter like: code]methode(i_param TYPE string)[/code]. In the calling methode the parameter value l_value for i_param is stored in a variable from type c. In java I would like call: methode((string) l_value) (For

  • Dynamic link after effects and adobe media encoder

    Hello, I recently downloaded After Effects cc (yesterday). I am running a mac pro with OSX 10.9.3 2.3 ghz intel core i7 with 16 gb 1600 MHz DDR3. On previous versions of AE I was able to render straight out of AE, I know this is not the case with CC

  • How do I remove a "created" case sensitive disk image?

    Thanks for taking the time to read this, and thanks in advance for any and all advice. =) I used this command in an effort to ready my machine for android sdk and kernel editing (more exploratory and self education than actual editing). I want to und

  • Time Capsule broke my AirTunes!!!

    I've just installed a Time Capsule (working great!); however, now I can longer see or connect to my Airport Express and use AirTunes. When I open up AirPort Utility all it see is Time Capsule, no Airport Express. Anyone out there know what I should d