FILE DOWNLOAD CLASS?

Hi I am working on a webpage that allows the user to download
files from the server. However i am not sure how to modify the code
to show the download status so the user knows its actually download
sumthing - i was under the impression that this is supposed to show
automatically - if so - whats wrong with my code that is not
allowing this to display?
the code i am using is as follows:
on(release){
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
listener.onProgress = function(file:FileReference,
bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + "
bytesTotal: " + bytesTotal);
listener.onComplete = function(file:FileReference):Void {
trace("onComplete: " + file.name);
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
var url:String = "
http://www.website.com/thefile.jpg";
if(!fileRef.download(url, "thefilejpg")) {
trace("dialog box failed to open.");
In IE my photos download - but i dont see the download status
- same with mp3s
In FireFox - nothing happens at all even though i get the pop
up window asking the location to dowload the file.
help please!

this is good - i have done just that - but i noticed that the
download process only works in IE 7 and not previous IE's or
Firefox!!??
is this a known issue?...is there additional code needed to
make the FileRef class more browser friendly?

Similar Messages

  • How to download a text file using classes

    Hi Guys
    I want to download a text file using classes.
    Any idea how to do it ?
    Thanks
    Sameer

    HI sameer,
       It is no different from using a Function module.
    example:
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                  = w_fpath
        append                    = SPACE
          write_field_separator     = 'X'
        CHANGING
          data_tab                  = it_download
        EXCEPTIONS
          file_write_error          = 1
          no_batch                  = 2
          gui_refuse_filetransfer   = 3
          invalid_type              = 4
          no_authority              = 5
          unknown_error             = 6
          header_not_allowed        = 7
          separator_not_allowed     = 8
          filesize_not_allowed      = 9
          header_too_long           = 10
          dp_error_create           = 11
          dp_error_send             = 12
          dp_error_write            = 13
          unknown_dp_error          = 14
          access_denied             = 15
          dp_out_of_memory          = 16
          disk_full                 = 17
          dp_timeout                = 18
          file_not_found            = 19
          dataprovider_exception    = 20
          control_flush_error       = 21
          not_supported_by_gui      = 22
          error_no_gui              = 23
          OTHERS                    = 24
    Regards,
    ravi

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

  • How to make a jar file downloadable with IE

    hello,
    I just bought a website:
    http://www.frozenfountain.net/
    and I put a jar file on it called Logo.jar
    Using Mozilla, the jar file downloads as expected, but with Internet Explorer, it tries to download it as .zip file.
    How do I get it to download as a .jar file with IE?
    thanks

    Just post a link to the Jar. Mozilla will download
    it as a jar. Windows will download it as a zip.
    Only one link. No problem, really. ;-)There is a problem. People who arent as good with computers as you are won't know how to run the jar file after downloading with IE.
    At school, I told someone to download the file, which they did with IE. It downloaded to desktop as a zip. They extracted and were left with a bunch of .class files.
    On a sidenote, how do you draw text with a gradient?

  • File download in CRM WEB UI

    Hi ,
    I am using web ui .
    I have a requirement of converting an internal table to xml file & download it to application server .
    I have converted the file to xml but not able to save the file to application server  .I am currently using CL_CRM_FRONTEND_SERVICES=>GUI_DOWNLOAD method to download on application server  , but it is throwing an exception of "flush" but at the same time if i am calling this method from a report through SE38, it is working fine .
    Is there any other method that is to be used for CRM WEB UI to download a file on desktop / application server .
    Manish

    GUI DOWNLOAD will not work in WebClient, as it is a completely different technology. You will have to use some kind of technology that uses HTTP. Just like in the Internet.
    When you have got your content ready, maybe it is an option for you to transform it to XSTRING. There are some function modules in FM Group SCMS_CONV. Once you have got the XSTRING you can set it on a response object of class CL_HTTP_RESPONSE. Create a new one.
    Now declare yourself an URL. In your viewcontroller you have got access to the variable RUNTIME.
    concatenate runtime->application_url '/234234234.xml' into lv_url'
    when you have both you can upload the content to the server cache:
    cl_http_server=>server_cache_upload( url = lv_url response = lr_response ).
    now you can access the content under the created URL lv_url.
    On the BSP page you could for instance do this using javascript:
    window.open( lv_url ).
    This should open a dialog for the user with save option.
    cheers Carsten

  • Creating a file download link on jsp

    I have the following on my jsp. The code worked fine until I tried to use it in a new html design page.
    <code>
    //page name is index.jsp
    try //DISPLAY THE CONTENTS OF THE DATA DIRECTORY
    File dirname = new File(PATH); // create an instance of the File class
    if (dirname.exists()&&dirname.isDirectory())//check to see if File class dirname exists and is valid
    String [] allfiles = dirname.list();//create an array of files in the dirname File class
              for (int i=0; i< allfiles.length; i+=2)//loop through allfiles[] and print out file links
    out.println("<br><table border='1' cellspacing='1' width='99%'>");
                   out.println("<tr><td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i]+"'>"+allfiles[i]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td>
    <% if(i+1 < allfiles.length)//PRINTS OUT THE SECOND TD SO THAT WE HAVE 2 COLUMNS OF LINKS
    out.println("<td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i+1]+"'>"+allfiles[i+1]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td></tr>
    <%
    out.println("</form></font></table>");
    catch (IOException excep)
         out.println("An IO exception has occured.");
    </code>
    Then when clicked this code is run:
    <code>
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
    if (request.getParameter("downfile") != null)
    String filePath = request.getParameter("downfile");
    File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
    if (f.exists() && f.canRead())
    response.setContentType ("application/octet-stream");
    response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
    response.setContentLength((int) f.length());
    BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
    int i;
    out.clearBuffer();
    while ((i = fileInputStream.read()) != -1) out.write(i);
    fileInputStream.close();
    out.flush();
    </code>
    When I click on this link I get the download dialog box. If I open it I get the following open up in notepad(the files I am trying to give download links are .txt files)
    Below is what is displayed in notepad ALL on 1 line:
    <html>
    <head>
    <LINK rel="stylesheet" ty
    That is displayed in all of the links that I click on. It is the first few lines of html code for index.jsp.
    I know this code is probably not a good way of doing what I need but I got it to work fine until the change.
    I am sure there is an easier way to code the download link without resubmitting the page.
    Thanks in advance!!

    Well all was fine with this jsp until I moved it to ApacheJServ. Now the problem has resurfaced(although it is a little different now)
    I had moved the following code to the top of my page:
    //CHECK TO SEE IF EITHER DOWNFILE OR ZIPFILE VARIABLE EXIST, AND IF THEY DO SET CONTENT TYPE BEFORE SENDING ANY HTML CODE TO THE BROWSER
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
        if (request.getParameter("downfile") != null)
                String filePath = request.getParameter("downfile");
                File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
                    if (f.exists() && f.canRead())
                        response.setContentType ("application/octet-stream");
                        response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
                        response.setContentLength((int) f.length());
                        BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
                        int i;
                        out.clearBuffer();
                        while ((i = fileInputStream.read()) != -1) out.write(i);
                            fileInputStream.close();
                            out.flush();
                            response.flushBuffer();
    catch (Exception e){}
    //This is where the java code ends and the javascript/html code begins.Then further into the page I create the file download links like so:
                            <a class="a" href="main.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a>I know this isnt a secure way of doing this but I am on a intranet.
    The problem I am having now is that when I click on one of the links and download the file and then open it, I get the contents of the file plus concatenated to the end of it is the first few HTML lines of the actual jsp that I downloaded the file from. Before I was just getting the first few lines of html from the jsp, not the actual contents of the downloaded file.
    This is an example of what I am getting:
    This is the contents of the file that I downloaded.//This is where the file contents ends.
    <html>
    <head>
    <LINK rel="stylesheet" type="text/css" href="default.css">
    <script language="JavaScript1.2">
    //function that allows user to select all checkboxes
    function doIt(v)
    for(var i=0;i<document.form1.cb.length;i++)
       document.form1.cb.checked=eval(v);
    function swap(imageName,image)
    imageName.src = "templateImages/"+image;
    function imageOver(imageSrc, imageName)
         changeImage = new Image();
         changeImage.src = imageSrc;
         document.images[imageName].src = changeImage.src;
    var hide = true;
    function hideShow( ) /
    Any morre ideas?
    TIA!
    BTW, I went to ApacheJServ because they wont let me use tomcat :(

  • File download problem

    I am using the following code to present a file to the client to download when a report is generated. The code does what is suppose to, it presents a dialog box where the user can choose to open, save, or cancel the file download. However, when the file is downloaded it contains the client HTML at the bottom of the saved file. I checked the created file on the server and it does not contain the HTML at the bottom, so it is being added by the following jsp code when the file is presented to the user. Any help would be appreciated. BTW, this running on HP-UX 11i using oracle forms 10G.
       String RPT = request.getParameter("trig");
       String SDATE = request.getParameter("start_date");
       String EDATE = request.getParameter("end_date");
       String PRN = request.getParameter("prn");
    if(RPT != null)
         try {
              Runtime rt1;
              Process proc1;
              String[] doRefresh = {"/usr/bin/sh", "-c", "/usr/local/oracle/sql/st_tags/some_script '" + SDATE + "' '" + EDATE + "' '" + PRN + "'"};
              rt1 = Runtime.getRuntime();
              proc1 = rt1.exec(doRefresh);
              int exitVal = proc1.waitFor();
           String filename="/usr/local/oracle/sql/st_tags/temp/some_file.csv";
           response.setContentType("application/octet-stream");
           String disHeader="Attachment; Filename=some_file.csv";
           response.setHeader("Content-Disposition", disHeader);
           File fileToDownload=new File(filename);
           InputStream in=null;
           ServletOutputStream outs=response.getOutputStream();
           try {
              in=new BufferedInputStream
              (new FileInputStream(fileToDownload));
              int ch;
              while((ch=in.read()) != -1) {
              outs.print((char) ch);
           finally {
              if(in != null) in.close();
           outs.flush();
           outs.close();
           in.close();
         catch (Exception ignored) {}
       }

    Sorry, wasn't sure how important the HTML portion would be. Thanks for the response. Here is the HTML that is before and after the afore mentioned code.
    Before:
    <%@page import="java.lang.*, java.net.*, java.util.*, java.io.*"%>
    <%@page pageEncoding="UTF-8" contentType="text/html;charset=windows-1252"%>
    <%@page language="java" import="mil.uspfo.dpi.*" errorPage="default.jsp" %>
    <jsp:useBean id="AgnosticHostBean" class="mil.uspfo.dpi.AgnosticHostBean"
    scope="session">
    </jsp:useBean>
    <base href="http://<% out.print(AgnosticHostBean.getHostNameProperty() ); %>
    :7779/j2ee/">
    <html>
    <head>
    <title>Master Report</title>
    <link rel="stylesheet" type="text/css" href="styles/uspfo.css">
    </head>
    <body>
    <%@ include file="header.html" %>
    <h1>
    Master Report
    </h1>
    <form name="mstr_form" method="post">
    <p>Start Date:<input type="date" name="start_date">(example: YYYYMMDD)</p>
    <p>End Date  :<input type="date" name="end_date">(example: YYYYMMDD)</p>
    <p>Payroll # :<input type="text" name="prn"></p>
    <input type="SUBMIT" name="Button1" onClick="get_mstr_report()">
    <input type="hidden" name="trig" size="2">
    <br>
    <script type="text/javascript">
    function get_mstr_report() {
       document.mstr_form.trig.value="go";
    </script>AFTER:
    </form>
    <br>
    <%@ include file="footer.html" %>
    </body>
    </html>

  • File download from back end syetem to the user system

    Hi,
    This is very urgent requirement for me, can anybody help me regarding this:
    I have back end on one system and the front end on a different system. The use has login from third system.
    There is file on the back end system. User want to download that file using FTP to the local system. The Ftp download class is available at the back end system. Can anybody help me in sending the request from JSP to the back end to download the file from back end to the user's local system. FYI, I have to use core JSP/Servlet - support jre 1.4.2
    Thanks and Regards,
    braj

    hi,
    i tested this for you and the following code works fine. tested it on my 10.1.2 instance.
    declare
    l_new_item_master_id number;
    l_caid number := 33;
    l_folder_id number := 34373;
    begin
    portal.wwctx_api.SET_CONTEXT('portal','manager1','');
    portal.wwctx_api.set_nls_language(P_NLS_LANGUAGE => 'e');
    l_new_item_master_id := wwsbr_api.add_item(
    p_caid => l_caid,
    p_folder_id => l_folder_id,
    p_display_name => 'portal.doc',
    p_type_id => wwsbr_api.ITEM_TYPE_FILE,
    p_type_caid => wwsbr_api.SHARED_OBJECTS,
    p_description => 'This is the text of the review.',
    p_file_filename => '/home/oracle/test/portal.doc');
    wwpro_api_invalidation.execute_cache_invalidation;
    end;
    regards,
    christian

  • Help with HttpClient for file download

    I am writing a class to download files from a website.
    The site gave me a user name and password for login
    I need to write codes to login automatically using the userName and password the site gave me.
    Please I need some help on how to do this.
    Thanks
    Cypray

    The following in google returns a number of links that look like it discusses this. I know as well that the user/pwd issue has been discussed on this site before.
    java http "file download"

  • 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

  • XML file download to presentation server.

    Hi Experts,
    Here I have a question regarding file download to desktop.
    I have a report which will generate xml file. Once it is generated i would like to download to desktop.
    I tried with 'GUI_DOWNLOAD', but it is not working. It means the file is downlaoded to presentation server but when i opened it 'Page can't be displayed' message is comming.
    Could you pleas help me to solve this issue.
    Thanks in advance.
    Regards,
    Anil.G

    Hello,
    For processing XMLs always try to make use of the class CL_XML_DOCUMENT.
    You can download the XML stream to a local file using the method of EXPORT_TO_FILE class CL_XML_DOCUMENT.
    Further reading: [/people/uwe.schieferstein/blog/2010/10/17/visualizing-any-kind-of-xml-data-using-class-clxmldocument]
    BR,
    Suhas

  • File Download Open/Save Dialog

    I'm trying to enhance an existing Flex 2 application. The
    application communicates with a web application via HTTPService.
    The Flex application can upload files from the user's local hard
    drive to the web application where they are ultimately stored in a
    database. The Flex application also allows the user to download any
    of these previously uploaded/stored files. The class
    flash.net.FileReference is used to perform the download.
    Everything works fine. The only issue is that when the user
    initiates a file download, he/she is only prompted as to where to
    save the file. We would like to first give the user the option to
    open or save the file... essentially the dialog that
    Internet Explorer gives you when you download a file (.exe, .doc,
    .xls, etc.) directly from a web site. Is there a way to do this?
    Thanks in advance!
    Chris

    Can't access the user's hard drive, even to open a file. You
    need to use Adobe AIR for this.

  • FIle download not working in page fragment

    Hi All,
    I have to download a file . I am using Dynamic tab shell and in one pf my page fragement link to download a file is avaliable...
    I did a POC on jspx and its working fine but when i try to use the same code in my jsff (page frament ) its not working any idea that do i have to do anything specific to acheive the same..
    Thanks
    Shubhangi

    Shubhangi/Timo,
    was this resolved? I am having the same issue. File download works fine in a jspx page but the same code is not working when file download is used as part of a page fragment.
    I have a table column that has the filename as commandlink with a managed bean code as below.
    public oracle.binding.BindingContainer getBindings() {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
    public void downloadFile(ActionEvent actionEvent) {
    FacesContext fctx = FacesContext.getCurrentInstance();
    // myDocumentLocation specified in web.xml
    String DOCUMENTS_LOCATION =
    fctx.getExternalContext().getInitParameter("myDocumentLocation");
    if (DOCUMENTS_LOCATION == null) {
    // DOCUMENTS_LOCATION = "C:\\Documents and Settings\\xxloc\\";
    Application app = fctx.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = fctx.getELContext();
    ValueExpression valueExp =
    elFactory.createValueExpression(elContext, "#{row.OrderFileName}",
    Object.class);
    String s1 = (String)valueExp.getValue(elContext);
    System.out.println(s1);
    String filename = s1 ;
    File srcdoc =
    new File(DOCUMENTS_LOCATION + filename);
    if (srcdoc.exists()) {
    FileInputStream fis;
    System.out.println("exists");
    byte[] b;
    HttpServletResponse response =
    (HttpServletResponse)fctx.getExternalContext().getResponse();
    response.setContentType("application/x-download");
    response.setHeader("Content-Disposition",
    "attachment; filename=" + filename);
    response.setBufferSize(1024);
    // response.setContentLength((new Long(srcdoc.length())).intValue());
    OutputStream out = null;
    try {
    out = response.getOutputStream();
    } catch (IOException e) {
    e.printStackTrace();
    try {
    fis = new FileInputStream(srcdoc);
    int n;
    n = fis.available();
    while (n > 0) {
    b = new byte[n];
    System.out.println("b" +b);
    int result = fis.read(b);
    out.write(b, 0, b.length);
    if (result == -1)
    break;
    } catch (IOException e) {
    System.out.println("in file error");
    e.printStackTrace();
    try {
    out.flush();
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    fctx.responseComplete();
    It would be great if someone could guide me with this issue.
    Thanks,
    RAS

  • PDF file downloading from server to client

    Hello,
    I am a newbie to Oralce UCM. Writing a component to merge some PDF files and allow user to save/open it on client side.
    The file downloaded is of 0 bytes and when opened it says -
    Adobe Reader could not open the the file because it is either not a suppported file type or because the file is damaged(It was sent as an email attachment and was not correctly decoded)
    this.m_binder.m_contentType = "application/pdf";
    this.m_binder.m_clientEncoding = "utf-8";
    DataStreamWrapper dataStreamWrapper = this.createNewDownloadStream();
    dataStreamWrapper.m_clientFileName = "MergedPDF";
    dataStreamWrapper.m_inStream = mergedPDF.getDocumentInputStream();
    dataStreamWrapper.m_inStreamActive = true;
    dataStreamWrapper.m_dataType = "application/pdf";
    try {
    this.m_httpImplementor.sendStreamResponse(this.m_binder, dataStreamWrapper);
    } catch (ServiceException e) {
    e.printStackTrace();
    Some clue would really help :)
    Thanks,
    Fauzia

    Hi Jiri,
    I have created and HCSP page where data is being populated dynamically. User may select some of the files from this page through checkbox. Page also has a download button which when clicked will merge all the selected documents and let the user open/save it.
    Information like Native URL, docName is passed on to the content server when the component is called (download button-click).
    Merging the PDFs, I have used a custom utility which takes url as a parameter and returns back the inputstream of merged PDF.
    And last, I have used DataStreamWrapper to send this inputstream back to the client as an attachment which can be read by IE.
    Also, I thought at first to use HTTPHeader where parameters like content-disposition, content-type can be set. But UCM already provides a better way to achieve this i.e. through DataStreamWrapper.
    public class MergePDF extends Service {
         public List<PdfDocumentSource> createPdfDocumentSourceList(
                   String... urlStrings) throws MalformedURLException {
              List<PdfDocumentSource> sourceList = new ArrayList<PdfDocumentSource>(
                        urlStrings.length);
              for (String url : urlStrings) {
                   URL urlDoc = new URL(url);
                   PdfDocumentSource pdfSource = new UrlPdfDocumentSource(urlDoc);
                   try {
                        System.out.println("URL in create method - "+urlDoc);
                        System.out.println("PDFSource input stream - "+pdfSource.getDocumentInputStream().available());
                   } catch (IOException e) {
                        e.printStackTrace();
                   sourceList.add(pdfSource);
              return sourceList;
         public void mergeAll() throws DataException, ServiceException {
              Properties property = this.m_binder.getLocalData();
              String urlStrings = "";
              List<PdfDocumentSource> sourceList;
              PdfDocumentSource mergedPDF = null;
              urlStrings = property.getProperty("webURL");
              String[] urls = urlStrings.split(";");
              try {
                   sourceList = createPdfDocumentSourceList(urls);
                   PdfMerge merge = new PdfMerge(sourceList, true);
                   try {
                        mergedPDF = merge.createMergedPdf();
                        transferToClient(mergedPDF);
                   } catch (PdfProcessingException e) {
                        e.printStackTrace();
              } catch (MalformedURLException e) {
                   e.printStackTrace();
              System.out.println("hello123");
              System.out.println("URLS - "+urlStrings);
         public void transferToClient(PdfDocumentSource mergedPDF){
              this.m_binder.m_contentType = "application/pdf";
              this.m_binder.m_clientEncoding = "utf-8";
              DataStreamWrapper dataStreamWrapper = this.createNewDownloadStream();
              dataStreamWrapper.m_clientFileName = "MergedPDF.pdf";
              dataStreamWrapper.m_inStream = mergedPDF.getDocumentInputStream();
              //dataStreamWrapper.m_inStreamActive = true;
              dataStreamWrapper.m_dataType = "application/pdf";
              try {
                   this.m_httpImplementor.sendStreamResponse(this.m_binder, dataStreamWrapper);
              } catch (ServiceException e) {
                   e.printStackTrace();
              * StringBuffer sb = this.createHttpResponseHeader();
              sb.append("Content-Type: application/pdf");
              sb.append("Content-Disposition: attachment; filename=fname.ext");
              //m_headerStr
              this.m_headerStr = sb.toString();
    }

  • When i try to run my jsp i get "File Download Security Warning"

    Hi,
    I have created a jsp file which is called UpdateEmpDetails1.jsp
    This jsp file picks up the employee id of the employee and transfers it to the backend servlet called UpdateEmpDetails1.java. The backend servlet looks up the table stored in the database and pulls up all the information stored corresponding to the employee id.Then the servlet stores the information in a session object and forwards it to the UpdateEmpDetails2.jsp
    I display the information which has been forwarded by the servlet in the HTML fields of UpdateEmpDetails2.jsp.
    Here the manager can also update the information. When he clicks on submit, the second serlvet UpdateEmpDetails2.java which is linked to UpdateEmpDetails2.jsp picks up the updated information and updates the database. The servlet also displays the message "Your information has been updated". But here is the real problem
    The session variables are being transferred perfectly to the jsp file UpdateEmpDetails2.jsp.
    But when i make any changes to this file and click on submit I get File Download Security Warning. It Says:
    File Download Security Warning
    Do you want to save this file
    Name UpdateEmpDetails2
    Type UnknownFileType
    From LocalHost
    Then I get another file which says
    FileDownload
    Getting FIle Information
    UpdateEmpDetails2 from localhost
    Estimated time left
    Download to:
    Transfer rate:
    Close this dialog box when download is complete
    I am just simply not able to update the employee information in the database due to this message.

    this is what i am trying to do:
    my UpdateEmpDetails1.jsp is as follows:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional //EN">
    <html>
    <head>
    <title>UpdateEmpDetails1.jsp</title>
    <link REL=STYLESHEET
    HREF="JSP-Styles.css"
    TYPE="text/css">
    </head>
    <body BGCOLOR="lightyellow" text="black">
    <h2 align="left"><font color="black">Update Employee Details Page</font></h2>
    <form action="UpdateEmpDetails2" Method="Get">
    <h2 align="left">Please enter the Employee ID of the employee whose details you want to edit</h2>
    <table width=50% align="center">
    <tr><td>Employee ID : </td>
         <td><INPUT TYPE="TEXT" name="employeeid"><br></td></tr>
    <tr><td><center><INPUT TYPE="SUBMIT" VALUE="SUBMIT"></center></td></tr>
    <tr><td><center><INPUT TYPE="RESET" VALUE="RESET"></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    my update EmpDetails1.java is as follows:
    package com.update;
    import com.database.*;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    public class UpdateEmpDetails1 extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              HttpSession session = request.getSession();
              String X = request.getParameter("employeeid");
              System.out.println("Employee ID:" + X);
              //Establishing the jdbc connection
              try
                   Database db = new Database();
                   Connection con = db.useConnection();
                   String query = "Select * from employees where employeeid=?";
                   PreparedStatement stat = con.prepareStatement(query);
                   System.out.println(stat);
                   stat.setString(1,X);
                   ResultSet rs = stat.executeQuery();
                   while(rs.next())
                        String A = rs.getString("employeeid");
                        String B = rs.getString("firstname");
                        String C = rs.getString("lastname");
                        String D = rs.getString("gender");
                        String E = rs.getString("dateofbirth");
                        String F = rs.getString("address");
                        String G = rs.getString("postalcode");
                        String H = rs.getString("phone");
                        String I = rs.getString("mobile");
                        String J = rs.getString("designation");
                        String K = rs.getString("joindate");
                        String L = rs.getString("leavedate");
                        String M = rs.getString("email");
                        String N = rs.getString("qualification");
                        String O = rs.getString("empstatus");
                             System.out.println("comparison successful");
                             session.setAttribute("employeeid",A);
                             session.setAttribute("firstname", B);
                             session.setAttribute("lastname", C);
                             session.setAttribute("gender", D);
                             session.setAttribute("dateofbirth", E);
                             session.setAttribute("address", F);
                             session.setAttribute("postalcode", G);
                             session.setAttribute("phone", H);
                             session.setAttribute("mobile", I);
                             session.setAttribute("designation", J);
                             session.setAttribute("joindate", K);
                             session.setAttribute("leavedate", L);
                             session.setAttribute("email", M);
                             session.setAttribute("qualification", N);
                             session.setAttribute("empstatus", O);
                             String url="/UpdateEmpDetails2.jsp";
                             RequestDispatcher dis = request.getRequestDispatcher("/UpdateEmpDetails2.jsp");
                             System.out.println("Dispatching" + dis);
                             dis.forward(request, response);
              catch(Exception e)
                   System.out.println(e);
    my UpdateEmpDetails2.jsp is as follows:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>UpdateEmpDetails2.jsp</title>
    <link REL=STYLESHEET
    HREF="JSP-Styles.css"
    TYPE="text/css">
    </head>
    <body BGCOLOR="lightblue" text="black">
    <h1 align="center"><font color="black">Update Employee Details Page</font></h1>
    <form action="UpdateEmpDetails2" Method="Get">
    <table width=50% align="center">
    <tr><td>EMPLOYEE ID:</td>
         <td><INPUT TYPE = "HIDDEN" name="employeeid" value=<%=session.getAttribute("employeeid")%> ></td></tr>
    <tr><td>FIRST NAME :</td>
         <td><INPUT TYPE = "TEXT" name="firstname" value=<%=session.getAttribute("firstname")%> ></td></tr>
    <tr><td>LAST NAME :</td>
         <td><INPUT TYPE = "TEXT" name="lastname" value=<%=session.getAttribute("lastname")%> ><br></td></tr>
    <tr><td>GENDER :</td>
         <td><INPUT TYPE = "TEXT" name="gender" value=<%=session.getAttribute("gender")%> ><br></td></tr>
    <tr><td>DATE OF BIRTH (IN MM/DD/YYYY FORMAT) :</td>
         <td><INPUT TYPE = "TEXT" name="dateofbirth" value=<%=session.getAttribute("dateofbirth")%> ><br></td><tr>
    <tr><td>ADDRESS :</td>
         <td><INPUT TYPE = "TEXT" name="address" value=<%=session.getAttribute("address")%> ><br></td></tr>
    <tr><td>POSTALCODE:</td>
         <td><INPUT TYPE = "TEXT" name="postalcode" value=<%=session.getAttribute("postalcode")%>><br></td></tr>
    <tr><td>PHONE:</td>
         <td><INPUT TYPE = "TEXT" name="phone" value=<%=session.getAttribute("phone")%> ><br></td></tr>
    <tr><td>MOBILE:</td>
         <td><INPUT TYPE = "TEXT" name="mobile" value=<%=session.getAttribute("mobile")%> ><br></td></tr>
    <tr><td>DESIGNATION : </td>
    <td><INPUT TYPE="TEXT" name="designation" value=<%=session.getAttribute("designation")%> > <br></td></tr>
    <tr><td>JOIN DATE:</td>
         <td><INPUT TYPE = "TEXT" name="joindate" value=<%=session.getAttribute("joindate")%> ><br></td></tr>
    <tr><td>LEAVE DATE:</td>
         <td><INPUT TYPE = "TEXT" name="leavedate" value=<%=session.getAttribute("leavedate")%> > <br></td></tr>
    <tr><td>EMPLOYEE EMAIL:</td>
         <td><INPUT TYPE = "TEXT" name="email" value=<%=session.getAttribute("email")%> ><br></td></tr>
    <tr><td>EMPLOYEE QUALIFICATION:</td>
         <td><INPUT TYPE = "TEXT" name="qualification" value=<%=session.getAttribute("qualification")%> > <br></td></tr>
    <tr><td>EMPLOYEE STATUS:</td>
         <td><INPUT TYPE = "TEXT" name="empstatus" value=<%=session.getAttribute("empstatus")%> > <br></td></tr>
    <tr><td><center><INPUT TYPE="SUBMIT" VALUE="SUBMIT"></center></td></tr>
    <tr><td><center><INPUT TYPE="RESET" VALUE="RESET"></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    my UpdateEmpDetails2.java is as follows:
    package com.update;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.*;
    import javax.servlet.*;
    import com.database.*;
    public class UpdateEmpDetails2 extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              PrintWriter out = response.getWriter();
              response.setContentType("texthtml");
              String A = request.getParameter("employeeid");
              out.println(A);
              String B = request.getParameter("firstname");
              out.println(B);
              String C = request.getParameter("lastname");
              out.println(C);
              String D = request.getParameter("gender");
              out.println(D);
              String E = request.getParameter("dateofbirth");
              out.println(E);
              String F = request.getParameter("address");
              out.println(F);
              String G = request.getParameter("postalcode");
              out.println(G);
              String H = request.getParameter("phone");
              out.println(H);
              String I = request.getParameter("mobile");
              out.println(I);
              String J = request.getParameter("designation");
              out.println(J);
              String K = request.getParameter("joindate");
              out.println(K);
              String L = request.getParameter("leavedate");
              out.println(L);
              String M = request.getParameter("email");
              out.println(M);
              String N = request.getParameter("qualification");
              out.println(N);
              String O = request.getParameter("empstatus");
              out.println(O);
              try
              Database db = new Database();
              Connection con = db.useConnection();
              String query= "update employees set employeeid=?,firstname=?,lastname=?,gender=?,dateofbirth=?,address=?,postalcode=?,phone=?,mobile=?,designation=?,joindate=?,leavedate=?,email=?,qualification=? where employeeid=?";
              PreparedStatement stat = con.prepareStatement(query);
              stat.setString(1, B);
              stat.setString(2, C);
              stat.setString(3, D);
              stat.setString(4, E);
              stat.setString(5, F);
              stat.setString(6, G);
              stat.setString(7, H);
              stat.setString(8, I);
              stat.setString(9, J);
              stat.setString(10, K);
              stat.setString(11, L);
              stat.setString(12, M);
              stat.setString(13, N);
              stat.setString(14, O);
              stat.setString(15, A);
              System.out.println(stat);
              int i = stat.executeUpdate();
              if (i!= 0)
              System.out.println("The record has been updated");
              else
                   System.out.println("Sorry ! failure");
              ResultSet rs = stat.executeQuery("select * from employees");
              System.out.println(rs);
              while(rs.next())
                   out.print("<table border='1'>");
                   out.println(rs.getString(1) + "<br>");
                   out.println(rs.getString(2) + "<br>");
                   out.println(rs.getString(3) + "<br>");
                   out.println(rs.getString(4) + "<br>");
                   out.println(rs.getString(5) + "<br>");
                   out.println(rs.getString(6) + "<br>");
                   out.println(rs.getString(7) + "<br>");
                   out.println(rs.getString(8) + "<br>");
                   out.println(rs.getString(9) + "<br>");
                   out.println(rs.getString(10) + "<br>");
                   out.println(rs.getString(11) + "<br>");
                   out.println(rs.getString(12) + "<br>");
                   out.println(rs.getString(13) + "<br>");
                   out.println(rs.getString(14) + "<br>");
                   out.println(rs.getString(15) + "<br>");
                   out.print("<br>");
              catch (Exception e)
                   System.out.println(e);
                   e.printStackTrace();
    Now as soon as i click on the submit button of the first jsp i get "File Download security warning message"
    I am new to jsp and i am not able to troubleshoot this

Maybe you are looking for