Performance issues in file download servlet

        FileInputStream in = null;
        ServletOutputStream sos = res.getOutputStream();
          File f = new File(path);
          if(f.exists())  {
            in = new FileInputStream(f);
            int length = (int)f.length();
            byte[] input = new byte[length];
            res.setContentType ("application/octet-stream");
            res.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
            res.setContentLength(length);
            if(length != 0) {
              while ((in != null) && ((length = in.read(input)) != -1))  {   // read
                sos.write(input,0, input.length);   // write
          }Hi experts, the above is a block of code that sends a file to a client machine through servlet. One problem I am having now is that it frequently cause the server to run out of memory. Is it because of the way I read the FileInputStream is not efficient?
            byte[] input = new byte[length];
            if(length != 0) {
              while ((in != null) && ((length = in.read(input)) != -1))  {   // read
                sos.write(input,0, input.length);   // write
              }It seems that my code reads an entire file into memory before it writes anything to the client, so when there are many people downloading files, the server will run out of memory. Is it true?
I am not very familiar with the read() and write() methods in the inputstream and output stream classes. So I hope someone here can tell me whether the above code is indeed the cause of the problem. If not, then I can troubleshoot my other servlets and JSPs.
Thanks!

try not to create a byte[] with the file size
try to make it a fix one
e.g.new byte[1024]
treat it as a package to sendThanks. But is 1024 too small a size for sending files throught the internet? What is the best size to used?

Similar Messages

  • Issue with File Download(messageDownload) on Search Page.

    Hi,
    I created a custom OAF search page which fetches values from one table. The document in getting stored in my custom table in a BLOB colums and NOT in FND_LOBS.
    The table has 3 collumns along with others:
    1st is primary key (Record_Seq) ==> number data type
    2nd to store actual file name (File1Name) ==> varcahar2 data type
    3rd to store the actual uploaded data (File1Data) ==> BLOB data type
    The reason for having the “File1Name” is so that I can display the original file name of the document that was uploaded, instead of just the “view” in the search page results .
    On the File1Data BLOB and created a messageDownload for that under query results table with following details:
    ID : File1Data
    ItemStyle : messageDownload
    FileMIME Type : pdf
    Datatype : BLOB
    View Instance : LacEmpExposureVO1
    view Attribute : File1Name
    File View Attribute : File1Data
    When I click on the "File1Name" data hyperlink, it is opening only the first document corresponding to the first record in the search page results.
    For example, If my search page returns 10 rows then when I click on the file1name on any row, It is open the first row file name only.
    I have a primary key column(RECORD_SEQ) in the Table / EO / VO which is displayed in the search page results.
    Also one weird thing is happening:
    If I try to do this more than 2 times then it is opening the update page with the first record from the search page results…
    I tried to print the context and it is nul the first time, But the second time then context is changing to "update". Dont know how this is happening????
    Any advice is greatly appreciated as it is very crucial for me to get this resolved ASAP. I have looked at several forums and did a lot of things as advised in the forums . But nothing seems to work for me.
    Thanks,
    Mir
    CO code for the search page
    ===========================
    if (pageContext.getParameter("Create")!= null)
    System.out.println("Into LacEmpExposureCO in PROCESS FORM REQUEST with Context of CREATE");
    pageContext.setForwardURL
    ("OA.jsp?page=/lac/oracle/apps/lac/lacempexposure/webui/LacEmpExposureCreatePG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    true, //Retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
    OAWebBeanConstants.IGNORE_MESSAGES);
    else if ("update".equals(pageContext.getParameter(EVENT_PARAM)))
    System.out.println("Into LacEmpExposureCO in PROCESS FORM REQUEST with Context of UPDATE");
    System.out.println("LacEmpExposureCO ==> RecordSeq in PROCESS FORM REQUEST is: " + RecordSeq);
    HashMap params = new HashMap(1);
    params.put("RecordSeq", RecordSeq);
    pageContext.setForwardURL
    ("OA.jsp?page=/lac/oracle/apps/lac/lacempexposure/webui/LacEmpExposureUpdatePG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    params,
    true, //Retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO, // Do not display breadcrumbs
    OAWebBeanConstants.IGNORE_MESSAGES);
    else {           
    String strEvent = pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM);
    System.out.println(strEvent);
    System.out.println("Into the last ELSE part in LacEmpExposureCO.java");

    Duplicate post -- Issue with File Download(messageDownload) on Search Page.

  • Need urgent help on file download servlet problem in Internet Explore

    I have trouble to make my download servlet work in Internet Explore. I have gone through all the previous postings and done some research on the internet, but still can't figure out the solution. <br>
    I have a jsp page called "download.jsp" which contains a URL to download a file from the server, and I wrote a servlet (called DownloadServlet) to look up the corresponding file from the database based on the URL and write the file to the HTTP output to send it back to the browser. <br>
    the URL in download.jsp is coded like <a href="/download/<%= currentDoc.doc_id %>/<%= currentDoc.name %>">on the browser, it will be sth like , the number 87 is my internal unique number for a file, and "myfile.doc" is the real document name. <br>
    in my web.xml, "/download/" is mapped to DownloadServlet <br>
    the downloadServlet.java looks like
    tem_name = ... //read DB for file name
    // set content type
    if ( tmp_name.endsWith(".doc")) {
    response.setContentType("application/msword");
    else if ( tmp_name.endsWith(".pdf")){
    response.setContentType("application/pdf");
    else if ( tmp_name.endsWith(".ppt")){
    response.setContentType("application/vnd.ms-powerpoint");
    else if ( tmp_name.endsWith(".xls")){
    response.setContentType("application/vnd.ms-excel");
    else {
    response.setContentType("application/download");
    // set HTTP header
    response.setHeader("Content-Disposition",
    "attachment; filename=\""+tmp_name+"\"");
    OutputStream os = response.getOutputStream();
    //read local file and write back to browser
    int i;
    while ((i = is.read()) != -1) {
    os.write (i);
    os.flush();
    Everything works fine in Netscape 7.0, when I click on the link, Netscape prompts me to choose "open using Word" or "save this file to disk". That's exactly the behavior I want. <br>
    However in IE 5.50, the behavior is VERY STRANGE.
    First, when I click on the URL, the popup window asks me to "open the file from its current location" or "save the file to disk". It also says "You have chosen to download a file from this location, ...(some url).. from localhost"
    (1) If I choose "save the file to disk", it will save the rendered "download.jsp" (ie, the currect page with URL I just clicked, which isn't what I want).
    (2)But if I choose "open the file from its current location", the 2nd popup window replaces the 1st, which also has the "Open ..." and "Save.." options, but it says "You have chosen to download a file from this location, MYFILE.doc from localhost". (notice it shows the correct file name now)
    (3) If I choose "Save..." on the 2nd window, IE will save the correct file which is "myfile.doc"; if I choose "Open ...", a 3rd replaces the 2nd window, and they look the same, and when I choose "Open..." on the 3rd window, IE will use Word to open it.
    any ideas?
    </a>

    Did you find a solution to this problem? I've been wrestling with the same issues for the past six months. Nothing I try seems to work. I've tried setting the contentLength(), inline vs. attachments, different write algorythms, etc. I don't get the suggestion to rename the servlet to a pdf file.

  • Issue with file download from BLOB type data

    i have been using this for a while, with no problems, including on hosted machines.
    the upload to the database works fine.. not the issue, and the download script also works fine, on the local WAMP machine.
    but once moved to the server it fails.. the query does not work.
    i have a feeling that it is something to do with the managed hosting i am using, but they say no, i have tried it on 2 seperate hosted machines (different providers), with no joy.
    if i run the select query on the hoisting server via phpmyadmin, the query runs ok.
    any suggestions as to what may be causing the problem on the server compared to the local WAMP machine?
    i really don't know where to start looking, or where to point the hosting company.
    This is the php code to download the blob data, works fine on local WAMP setup, browser asks if you want to save the file/open etc. as expected.
    <?php require_once('Connections/connTracker.php'); ?>
    <?php
    // if id is set then get the file with the id from database
    if(isset($_GET['docindex']))
               {$id    = $_GET['docindex'];
            $query = "SELECT document_name, document_type, document_size, document_content " .
               "FROM tracker_documents WHERE document_index = ".$id;
    *** seems to be failing here when running the query ***
    $result = mysql_query($query) or die('Error, query failed');
               list($name, $type, $size, $content) = mysql_fetch_array($result);
         header("Cache-Control: maxage=1"); //In seconds
       header("Pragma: public");
         header("Content-length: $size");
               header("Content-type: $type");
               header("Content-Disposition: attachment; filename=$name");
               echo html_entity_decode ($content);}
    exit;
    ?>

    Hi Gun,
    You are the only one responded to my issue. I have allocated some points.
    Yes. I have checked the assignment in CRM organizational model.
    I did download the org. structure from ECC 5.0
    All objects including sales offices are activated for determination and I have verified with green light
    As per your suggestion if the sales area data is not matched between the two systems, then how come the error will not reappear during the bdoc reprocess?
    What is missing during the first time bdoc process? Looks something is missing for validation module?
    Any inputs?
    Thanks,
    Raj

  • Performance issues - Log file parallel write

    Hi there,
    Since a few months I have big performance issues with my Oracle 11.2.0.1.0.
    If I look in the Enterprise manager (in blocking sessions) I see al lot of "log file paralles writes" and a lot of "log file sync" .
    We have configured an active data guard environment and are using ASM.
    We are not stressing out the database with heavy queries or commits or something, but sometimes during the day this happens on non specific times...
    We've investigated everything (performance to SAN / heavy queries / oracle problems etc etc) and we really don't know what to do anymore so i thought.. let's try a post on the Forum.....
    Perhaps someone had similar things?
    Thanks,
    BR
    Mark

    mwevromans wrote:
    See blow a tail of alertlog.
    Tue Apr 24 15:12:17 2012
    Thread 1 cannot allocate new log, sequence 194085
    Checkpoint not complete
    Current log# 1 seq# 194084 mem# 0: +DATA/kewillprd/onlinelog/group_1.262.712516155
    Current log# 1 seq# 194084 mem# 1: +FRA/kewillprd/onlinelog/group_1.438.756466165
    LGWR: Standby redo logfile selected to archive thread 1 sequence 194085
    LGWR: Standby redo logfile selected for thread 1 sequence 194085 for destination LOG_ARCHIVE_DEST_2
    Thread 1 advanced to log sequence 194085 (LGWR switch)
    Current log# 2 seq# 194085 mem# 0: +DATA/kewillprd/onlinelog/group_2.264.712516155
    Current log# 2 seq# 194085 mem# 1: +FRA/kewillprd/onlinelog/group_2.418.756466215
    Tue Apr 24 15:12:21 2012
    Archived Log entry 388061 added for thread 1 sequence 194084 ID 0x90d7aa62 dest 1:
    Tue Apr 24 15:14:09 2012
    Thread 1 cannot allocate new log, sequence 194086
    Checkpoint not complete
    Current log# 2 seq# 194085 mem# 0: +DATA/kewillprd/onlinelog/group_2.264.712516155
    Current log# 2 seq# 194085 mem# 1: +FRA/kewillprd/onlinelog/group_2.418.756466215
    LGWR: Standby redo logfile selected to archive thread 1 sequence 194086
    LGWR: Standby redo logfile selected for thread 1 sequence 194086 for destination LOG_ARCHIVE_DEST_2
    Thread 1 advanced to log sequence 194086 (LGWR switch)
    Current log# 3 seq# 194086 mem# 0: +DATA/kewillprd/onlinelog/group_3.266.712516155
    Current log# 3 seq# 194086 mem# 1: +FRA/kewillprd/onlinelog/group_3.435.756466241
    Tue Apr 24 15:14:14 2012
    Archived Log entry 388063 added for thread 1 sequence 194085 ID 0x90d7aa62 dest 1:
    Tue Apr 24 15:16:46 2012
    Thread 1 cannot allocate new log, sequence 194087
    Checkpoint not complete
    Current log# 3 seq# 194086 mem# 0: +DATA/kewillprd/onlinelog/group_3.266.712516155
    Current log# 3 seq# 194086 mem# 1: +FRA/kewillprd/onlinelog/group_3.435.756466241
    Thread 1 cannot allocate new log, sequence 194087
    Private strand flush not complete
    Current log# 3 seq# 194086 mem# 0: +DATA/kewillprd/onlinelog/group_3.266.712516155
    Current log# 3 seq# 194086 mem# 1: +FRA/kewillprd/onlinelog/group_3.435.756466241
    LGWR: Standby redo logfile selected to archive thread 1 sequence 194087
    LGWR: Standby redo logfile selected for thread 1 sequence 194087 for destination LOG_ARCHIVE_DEST_2
    Thread 1 advanced to log sequence 194087 (LGWR switch)
    Current log# 1 seq# 194087 mem# 0: +DATA/kewillprd/onlinelog/group_1.262.712516155
    Current log# 1 seq# 194087 mem# 1: +FRA/kewillprd/onlinelog/group_1.438.756466165
    Tue Apr 24 15:16:54 2012
    Archived Log entry 388065 added for thread 1 sequence 194086 ID 0x90d7aa62 dest 1:
    Tue Apr 24 15:18:59 2012
    Thread 1 cannot allocate new log, sequence 194088
    Checkpoint not complete
    Current log# 1 seq# 194087 mem# 0: +DATA/kewillprd/onlinelog/group_1.262.712516155
    Current log# 1 seq# 194087 mem# 1: +FRA/kewillprd/onlinelog/group_1.438.756466165
    Thread 1 cannot allocate new log, sequence 194088
    Private strand flush not complete
    Current log# 1 seq# 194087 mem# 0: +DATA/kewillprd/onlinelog/group_1.262.712516155
    Current log# 1 seq# 194087 mem# 1: +FRA/kewillprd/onlinelog/group_1.438.756466165
    LGWR: Standby redo logfile selected to archive thread 1 sequence 194088
    LGWR: Standby redo logfile selected for thread 1 sequence 194088 for destination LOG_ARCHIVE_DEST_2
    Thread 1 advanced to log sequence 194088 (LGWR switch)
    Current log# 2 seq# 194088 mem# 0: +DATA/kewillprd/onlinelog/group_2.264.712516155
    Current log# 2 seq# 194088 mem# 1: +FRA/kewillprd/onlinelog/group_2.418.756466215
    Tue Apr 24 15:19:06 2012
    Archived Log entry 388067 added for thread 1 sequence 194087 ID 0x90d7aa62 dest 1:
    Tue Apr 24 15:22:00 2012
    Thread 1 cannot allocate new log, sequence 194089
    Checkpoint not complete
    Current log# 2 seq# 194088 mem# 0: +DATA/kewillprd/onlinelog/group_2.264.712516155
    Current log# 2 seq# 194088 mem# 1: +FRA/kewillprd/onlinelog/group_2.418.756466215
    Thread 1 cannot allocate new log, sequence 194089
    Private strand flush not complete
    Current log# 2 seq# 194088 mem# 0: +DATA/kewillprd/onlinelog/group_2.264.712516155
    Current log# 2 seq# 194088 mem# 1: +FRA/kewillprd/onlinelog/group_2.418.756466215
    LGWR: Standby redo logfile selected to archive thread 1 sequence 194089
    LGWR: Standby redo logfile selected for thread 1 sequence 194089 for destination LOG_ARCHIVE_DEST_2
    Thread 1 advanced to log sequence 194089 (LGWR switch)
    Current log# 3 seq# 194089 mem# 0: +DATA/kewillprd/onlinelog/group_3.266.712516155
    Current log# 3 seq# 194089 mem# 1: +FRA/kewillprd/onlinelog/group_3.435.756466241
    Tue Apr 24 15:19:06 2012
    Archived Log entry 388069 added for thread 1 sequence 194088 ID 0x90d7aa62 dest 1:Hi
    1st switch time ==> Tue Apr 24 15:18:59 2012
    2nd switch time ==> Tue Apr 24 15:19:06 2012
    3rd switch time ==> Tue Apr 24 15:19:06 2012
    Redo log file switch has good impact on the performance of the database. Frequent log switches may lead to the slowness of the database . Oracle documents suggests to resize the redolog files so that log switches happen more like every 15-30 min (roughly depending on the architecture and recovery requirements).
    AS i check the alertlog file and find that the log are switchinh very fequent which is one of the reason that you are getting checkpoint  not complete message . i have face this issue many times and i generally increase the size of the logfile and set the archive_lag_time parameter as i have suggested above . If you further want to go root cause and more details then above guys will help you more because i don't have much experience in database tunning . If you looking for aworkarounf then you must go through it .
    Good Luck
    --neeraj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Working Sample Code: File Download Servlet

    Pardon the cross-posting (Java Servlet Technology), but when I was researching this problem I found alot of people asking this question in here as well as in the servlet forum. So I thought this code would be helpful here too.
    Here is a complete working servlet for downloading virtually any type of file to a browser.
    It uses a file called application.properties to specify the location of the folder where the files to be downloaded reside. Of course you could modify this to allow the users to select the location as well.
    A sample URL to call the Servlet would look like this:
    http://localhost/website/servlet/DownloadAssistant?YourFileName.ext
    I tested this with varying filenames. It did have some issues if the file contained special characters like # symbol. This should be manageable however.
    Hope someone finds this useful.
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.zip.GZIPOutputStream;
    public class DownloadAssistant extends HttpServlet
    private static final String DIR = "dir";
    private String separator;
    private String root;
    public DownloadAssistant()
    Properties propFile = null;
    FileInputStream in = null;
    String JAVA_HOME = "C:\\jrun\\servers\\default\\filetest\\application.properties";
    // Get a handle on the peoperties file
    try{
    in = new FileInputStream(JAVA_HOME);
    propFile = new Properties();
    propFile.load(in);
    catch (IOException ignore){}
    separator = "/";
    // Get the directory from the application.properties file
    // e.g. C:\\Temp\\Files\\
    root = propFile.getProperty("app.directory");
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest(request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    processRequest(request, response);
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    PrintWriter out = null;
    ServletOutputStream stream = null;
    GZIPOutputStream zipstream = null;
    Object obj = null;
    String s = "";
    //determine if there is a filename appended to the url
    // If so, then decode it
    s = HttpUtils.getRequestURL(request).toString();
    int i;
    if((i = s.indexOf("?")) > 0)
    s = s.substring(0, i);
    String s1;
    if((s1 = request.getQueryString()) == null)
    s1 = "";
    else
    //s1 = decode(s1);
    s1 = URLDecoder.decode(s1);
    // No filename, so set contentType and generate error message
    if(s1.length() == 0)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<p>Could not get file name ");
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Restriction while gaining access to the file
    if(s1.indexOf(".." + separator) > 0)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<br><br><br>Restrictions on filename");
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Try to get a handle on the file
    File file = new File(root + s1);
    // Couldn't get the file, return an error message
    if(file == null)
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html>");
    out.println("<p>Could not read file: " + s1);
    out.println("</html>");
    out.flush();
    out.close();
    return;
    // Either the file doesn't exist or it can't be read, return an error message
    if(!file.exists() || !file.canRead())
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("<html><font face=\"Arial\" size=\"+1\">");
    out.println("<p>Could not read file " + s1);
    out.print("<br>Reasons are: ");
    if(!file.exists())
    out.println("file does not exist");
    else
    out.println("file is not readable at this moment");
    out.println("</font></html>");
    out.flush();
    out.close();
    return;
    // Looks like we can read/access the file, determine its type
    String s2 = request.getHeader("Accept-Encoding");
    // Is this a zip file?
    boolean flag = false;
    if(s2 != null && s2.indexOf("gzip") >= 0)
    flag = true;
    flag = false;
    if(flag)
    response.setHeader("Content-Encoding", "gzip");
    response.setHeader("Content-disposition", "attachment;filename=" + s1);
    stream = response.getOutputStream();
    zipstream = new GZIPOutputStream(stream);
    downloadFile(root + s1, zipstream);
    zipstream.close();
    stream.close();
    // It's not a zip file so treat it as any other file
    else
    response.setContentType("application/force-download");
    response.setHeader("Content-disposition", "attachment;filename=" + s1);
    stream = response.getOutputStream();
    downloadFile(root + s1, stream);
    stream.flush();
    stream.close();
    }// end processRequest()
    // This method downloads the file to the browser
    private void downloadFile(String s, OutputStream outstream)
    String s1 = s;
    byte abyte0[] = new byte[4096];
    try
    BufferedInputStream instream = new BufferedInputStream(new FileInputStream(s1));
    int i;
    while((i = instream.read(abyte0, 0, 4096)) != -1)
    outstream.write(abyte0, 0, i);
    instream.close();
    catch(Exception _ex) { }
    }//end downloadFile()
    public void init(ServletConfig servletconfig)
    throws ServletException
    super.init(servletconfig);
    String s;
    if((s = getInitParameter("dir")) == null)
    s = root;
    separator = System.getProperty("file.separator");
    if(!s.endsWith(separator))
    s = s + separator;
    root = s;
    }//end init()
    }//end servlet()

    Yes - it is useful

  • Issue: XML File Downloading to Application Server

    Hi All,
    I am experiencing an issue downloading an XML File to the Application Server.
    I'm using FM SAP_CONVERT_TO_XML_FORMAT to convert SAP data to XML Format.
    After getting the XML data into XMLTAB, I'm using:
    OPEN DATASET pfile_fs FOR OUTPUT IN BINARY MODE .
         LOOP AT xmltab INTO xmltab_w.
         TRANSFER xmltab_w TO pfile_fs.
          CLEAR xmltab_w.
         ENDLOOP.
       CLOSE DATASET pfile_fs.
    The xml file is downloaded show an Error in 'XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:/shared/TEST/2009'
    But when i download xml file using the FM  WS_Download , the XML page has no errors .
    I am unable to figure out what could be the issue, If this issue is due to some characters like Chinese or Japanese then .. is there any solution for this .
    Please, give me your valuable suggestions.
    Thank you,
    Prasead

    Dear Prasead,
            Hope things are good at your end, i have got the same issue as well, could you please care to share the solution...Wud be of a gr8 help if you could do that, hope to have your response back.
    Regards,
    Abdul.

  • Speed issues in file parsing

    Hi everyone
    I am a commercial developer who is relatively new to Java technology. My company has just finished the initial version of a servlet-based web program which is designed to interact with a MySQL database.
    We are having a major performance issue, however. The servlet works by reading a raw HTML file on the server, and looking for field names (suggested by a marker). When it finds one, it replaces it with data from a resultset.
    One of the most common replacements is for an autotext field. We have a problem however, in that one of our clients has 5000 records, and the program is taking nearly 30 seconds (on a Pentium 3 800mhz, 500meg ram, running nothing else except Apache Tomcat 4.03) to do the lines of code which send the resultset to the html. Specifically, it does this -
    1. Reads the first entry in a vector.
    2. Adds a line to a new vector which contains the (revised) html code.
    3. Reads the next entry
    and so on for 5000 records, and then, later,
    1. Reads the first entry from the html (revised) vector
    2. out.println's the line to the HTMLServerresponse/
    3. Reads the next entry
    for 5000 records.
    In my thinking, reading a line of text and writing it to another vector should be faster than 10,000 records per 30 seconds.
    Any suggestions?
    Brendan

    Hi.
    1. Replace your Vectors with ArrayLists. This will stop mutexes having to be grabbed all the time
    2. Make sure your file processing and output uses buffers (BufferedInputStream/ BufferedOutputStream/ BufferedReader/ BufferedWriter) - this may make a significant difference
    But it sounds to me that what you are trying to do is treat the HTML as a template. You'd be better off using JSPs or Jakarta's Velocity stuff.
    Regards,
    Lance
    Lance Walton - [email protected]
    Team In A Box - Software without Tragedy
    http://www.teaminabox.co.uk

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

  • 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

  • SQLDeveloper 1.5.4 Table browsing performance issue

    Hi all,
    I had read of previous posts regarding SQLDeveloper 1.5.3 table browsing performance issues. I downloaded and installed version 1.5.4 and it appears the problem has gotten worse!
    It takes ages to display rows of this particular table (the structure is shown below). It takes much longer to view it in Single Record format. Then attempting to Export the data is another frustrating exercise. By the way, TOAD does not seem to have this problem so I guess it is a SQLDeveloper bug.
    Can someone help with any workarounds?
    Thanks
    Chiedu
    Here is the table structure:
    create table EMAIL_SETUP
    APPL_ID VARCHAR2(10) not null,
    EML_ID VARCHAR2(10) not null,
    EML_DESC VARCHAR2(80) not null,
    PRIORITY_NO_DM NUMBER(1) default 3 not null
    constraint CC_EMAIL_SETUP_4 check (
    PRIORITY_NO_DM in (1,2,3,4,5)),
    DTLS_YN VARCHAR2(1) default '0' not null
    constraint CC_EMAIL_SETUP_5 check (
    DTLS_YN in ('0','1')),
    ATT_YN VARCHAR2(1) default '0' not null
    constraint CC_EMAIL_SETUP_6 check (
    ATT_YN in ('0','1')),
    MSG_FMT VARCHAR2(5) default 'TEXT' not null
    constraint CC_EMAIL_SETUP_7 check (
    MSG_FMT in ('TEXT','HTML')),
    MSG_TMPLT VARCHAR2(4000) not null,
    MSG_MIME_TYPE VARCHAR2(500) not null,
    PARAM_NO NUMBER(2) default 0 not null
    constraint CC_EMAIL_SETUP_10 check (
    PARAM_NO between 0 and 99),
    IN_USE_YN VARCHAR2(1) not null
    constraint CC_EMAIL_SETUP_11 check (
    IN_USE_YN in ('0','1')),
    DFLT_USE_YN VARCHAR2(1) default '0' not null
    constraint CC_EMAIL_SETUP_12 check (
    DFLT_USE_YN in ('0','1')),
    TAB_NM VARCHAR2(30) null ,
    FROM_ADDR VARCHAR2(80) null ,
    RPLY_ADDR VARCHAR2(80) null ,
    MSG_SBJ VARCHAR2(100) null ,
    MSG_HDR VARCHAR2(2000) null ,
    MSG_FTR VARCHAR2(2000) null ,
    ATT_TYPE_DM VARCHAR2(4) null
    constraint CC_EMAIL_SETUP_19 check (
    ATT_TYPE_DM is null or (ATT_TYPE_DM in ('RAW','TEXT'))),
    ATT_INLINE_YN VARCHAR2(1) null
    constraint CC_EMAIL_SETUP_20 check (
    ATT_INLINE_YN is null or (ATT_INLINE_YN in ('0','1'))),
    ATT_MIME_TYPE VARCHAR2(500) null ,
    constraint PK_EMAIL_SETUP primary key (EML_ID)
    )

    Check Tools | Preferences | Database | Advanced Parameters and post the value you have there.
    Try setting it to a small number and report if you see any improvement.
    -Raghu

  • Report Print & Export Issue (File Download Box appears)

    We send a URL to Crystal Enterprise which runs a script, logs on, finds folder, finds report and displays in the Crystal report viewer. All that works fine....
    However, when you select the print icon or the export icon a Windows Internet Explorer box to select page range etc. and then when you say OK, you recieve a File Download Box asking to Open/Save/Cancel one of the following:
    Print - Name: CrystalViewer.pdf, and Type of pdf_auto_file
    Export - Name: CrystalViewer.rpt, and Type of CrystalReports
    I have no IDEA what he is trying to do but he sure ain't printing.  I can only assume that I have a missing part that he is trying to download at the time of print/export. Or that there is something set in the script that is killing me...
      Sub ViewReport( iStore, id, token)  
      URI = "./viewer/en/viewreport.csp?id=" & id & "&token=" & token & GetPrompt
       Set viewer = Server.CreateObject( "CrystalReports.CrystalReportViewer" )
       Set rptFactory = iStore.EnterpriseSession.Service("", "PSReportFactory")
       Set rptSource = rptFactory.OpenReportSource(CInt(id))
       ' Set the viewer's properties to prepare it for viewing.
       With viewer
          .ReportSource       = rptSource
          .EnterpriseLogon    = iStore.EnterpriseSession
          .URI                = URI
          .ISOWNPAGE          = TRUE
          .ISOWNFORM          = TRUE
          .HasPrintButton     = TRUE
          .ISDISPLAYPAGE      = true
          .isdisplaytoolbar   = true
          .isDisplayGroupTree = true
          .GroupTreeWidthUnit = 1
          .GroupTreeWidth     = 17
          .HasRefreshButton   = true
          .HasExportButton    = true
          .ParameterFields    = GetParams
       End With
        If Err.Number <> 0 Then
          'There was an error setting up the viewer.
          Response.Write "<p>Unable to create report viewer. " & Err.number
       Else
          'Process the request and launch the viewer.
          viewer.ProcessHttpRequest Request, Response, Session
          'viewer.refresh
       End If
    End Sub
    Help me???

    Please re-post if this is still an issue to the .NET Development - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly

  • Multiple file download issues

    Hi All,
    I have designed an APEX application to download multiple files. I have check box in each row of the file name and a download button.
    When the users checks set of checkboxes and click on the "Download" Button, i am expecting the marked files to be downloaded. I am encountering the below issues in this implementation(i.e single file download is fine):
    1. When ticks all the check boxes and click download, the files are never downloading. The target URL goes something like this :
    www.example.com/abc/bcd/wwv_flow.accept
    and there is a cross icon in the new page. No download happening.
    2. When ticks few files and leave rest of the files un-checked, there are either junk charactes in target page (or) only the last checked box file alone downloading.
    Please refer the code below and advice. Thanks very much in advance.
    Code:
    =====
    declare
    check_box_val varchar2(500):=' ';
    file_name varchar2(500):=' ';
    begin
    for i in 1..htmldb_application.g_f01.count
    loop
    check_box_val:=nvl(htmldb_application.g_f02(i),' ');
    if(check_box_val<>' ') then
    sho_pdf(check_box_val);
    end if;
    end loop;
    exception
    when others then
    null;
    end;
    sho_pdf.sql
    ========
    CREATE OR REPLACE PROCEDURE FDM_UAT14.sho_pdf(p_file in varchar2)
    AS
    l_blob BLOB;
    l_bfile BFILE;
    BEGIN
    DBMS_LOB.createtemporary (l_blob, TRUE, DBMS_LOB.SESSION);
    l_bfile := BFILENAME ('UPDOWNFILES_DIR', p_file);
    DBMS_LOB.fileopen (l_bfile);
    DBMS_LOB.loadfromfile (l_blob, l_bfile, DBMS_LOB.getlength (l_bfile));
    DBMS_LOB.fileclose (l_bfile);
    OWA_UTIL.mime_header ('application/octet',
    bclose_header => FALSE);
    HTP.p ('Content-length: ' || DBMS_LOB.getlength (l_blob));
    HTP.p( 'Content-Disposition: filename="' || p_file || '"' );
    OWA_UTIL.http_header_close;
    WPG_DOCLOAD.download_file (l_blob);
    DBMS_LOB.freetemporary (l_blob);
    EXCEPTION
    WHEN OTHERS
    THEN
    NULL;
    END;
    /

    I have read that "patch number 8548651" need to be applied in order to download multiple files in Single Page. Is it true? Pls refer this page :
    http://dgielis.blogspot.com/2010/01/oracle-application-express-patch-set.html
    8555172 -- BLOB download links are incorrect when multiple file items referenced on a page.

  • Problem in downloading file using servlet

    Hello,
    I wnat to send a file throung servlet to my desktop program. when i call this servlet through internet explore it is working fine but when i call this in my desktop program then desktop program get nothing. my desktop program does not get anything. please help me. here is my both code servlet and desktop program.
    public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              response.setContentType("text/html");
         //     PrintWriter out = response.getWriter();
              File filename = new File("");
    //          Set the headers.
              response.setContentType("application/x-download");
              response.setHeader("Content-Disposition", "attachment; filename=" + filename);
    //          Send the file.
              OutputStream out = res.getOutputStream( );
              returnFile(filename, out); // Shown earlier in the chapter
              String filePath = getServletContext().getRealPath("/");
              response.setContentType("application/x-download");
              response.setHeader("Content-Disposition", "attachment; filename="+"amit.doc");
         //     File tosave = new File(getServletContext().getRealPath("), cfile.getName());" +
              try{
              File uFile= new File(filePath);
              int fSize=(int)uFile.length();
              FileInputStream fis = new FileInputStream(uFile);
              PrintWriter pw = response.getWriter();
              int c=-1;
    //          Loop to read and write bytes.
    //          pw.print("Test");
              while ((c = fis.read()) != -1){
              pw.print((char)c);
    //          Close output and input resources.
              fis.close();
              pw.flush();
              pw=null;
              }catch(Exception e){
    public class AdDesktopClient {
         * @param args
         public static void main(String[] args) {
              try{ 
              URL url = new URL("http://localhost:8080/WebRoot1/servlet/Download");
              //URLEncoder.encode(xmlString);
              URLConnection connection = url.openConnection();
              HttpURLConnection con = (HttpURLConnection)connection;
              con.setDoInput(true);
              con.setDoOutput(true);
              con.setUseCaches(true);
              con.setRequestMethod("GET");
              // PrintWriter out = new PrintWriter(con.getOutputStream());
              BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
              String inputLine;
              int len = con.getContentLength();
              InputStream inn = con.getInputStream();
              byte[] buf = new byte[128];
              int c =0;
              System.out.print("len :"+len);
              System.out.print(inn.read());
              while( (c = inn.read())!= -1){
                   System.out.print(c);
    /*          while ((inputLine = in.readLine()) != null)
              System.out.println(inputLine);
              in.close();
              }catch(Exception e){
                   e.printStackTrace();
    Plaease help me to solve this problem. i want to send a file throuhg a servlet to my desktop program.
    Thanks in advance
    Ravi

    Give this a try:
    File strFile = new File(strFileName);
    long length = strFile.length();
    response.setContentType("application/octet-stream");
    response.setContentLength((int)length);
    response.setHeader("Content-Disposition", ("attachment; filename=" + strFileName));
    OutputStream out = response.getOutputStream();
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(strFile));
    int i = -1;
    while((i = in.read()) != -1) out.write(i);
    in.close();
    Kris

  • Issue when implementing file download in OAF

    Hi,
    We are trying to download some data and create a excel file in the click of a button in the OAF screen. And the requirement is to navigate to the previous screen automatically after the file download. I have used pageContext.forwardImmediately()
    to navigate to the previous page after the download code, but the issue is during download control goes out of OAF screen and user saves the file on the desktop after that the control doesnot come back and move to the next screen.
    Any pointers has how to acheive this requirement would be of great help.
    Thanks in Advance,
    Raji

    Raji,
    How are you implementing the file download? If you are not using OAMessageDownloadBean, I would suggest to use it to make the process navigation easier.
    --Shiv                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • The complete steps to bring to factory settings

    Hi... This is my first Mac experience, thus please bear with me. My MacBook Pro 15" 1.83 GHz had been running fine. Since the first time I started it up, I had never undergone a single hang. Not even a single hang during low or high load, eventhough

  • Bridge CS3 Does Not Display Pentax PEF files

    Hi, I am running Vista and have Bridge CS3 installed on my Notebook. I updated Bridge to v 2.1.1.9 and have added Camera RAW 4.5. My problem is that Bridge does not display Pentax RAW files from a K20 camera (its on the supported list). DNG and JPG f

  • Next Thinkstation wish list

    Hi folks, Lenovo is pretty innovative stuff, I think we can all agree As the Thinkpad is "inspired by customers", let's see if we could try and inspire Lenovo's system builders for the next generation of Thinkstation's to come, no doubt pretty soon g

  • When we will use BPM?.

    When we will use BPM in a scenario?. Why we use BPM?. If we can do same scenario without using BPM, is it better?.

  • Project mix window button problem

    Hi all This is driving me Nuts! When I press Window on my Project Mix Logic cycles though all the windows it will only stop when I random press zoom or other buttons I want to be able to press the window button and select each window on each press. c