Download file servlet

Hi, I have a servlet that downloads files. I was able to set the default download filename with the following code:
response.setHeader("Content-Disposition", "attachment; filename="+downloadName);
Is it posible to specify the default directory to save the file ? I mean is there any way to tell the browser to open the save dialog with a defaul directory selected?
Thanks in advance

Hi, I have a servlet that downloads files. I was able
to set the default download filename with the
following code:
response.setHeader("Content-Disposition",
"attachment; filename="+downloadName);
Is it posible to specify the default directory to
save the file ? I mean is there any way to tell the
browser to open the save dialog with a defaul
directory selected?
Thanks in advanceNo.
The server knows nothing about the browser's operating system, and therefore can't specify a path. What does C:\Documents and Settings\Current User\Desktop mean to a macintosh or a *nix machine?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Download file servlet problem

    hello
    i have a file stored in a byte[] form now i am using a servlet call for a link it works fine
    i get byte[] from database no i want that instead of making a file i can use this byte[] for the user as a file
    in short i have a link which calls a servlet it get byte[] from database how can i use this for user to get file as download file with out writing to server as file i just want these bytes to flush out??
    advance thanks
    Shakeel abbas

    thanks BALUSC
    the problem is solved as
    ServletOutputStream op = response.getOutputStream();
                        int length = 0;
                        byte[] bbuf = new byte[invoice.getInvoiceFile().length];
                        ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(invoice.getInvoiceFile());
                        DataInputStream in = new DataInputStream(arrayInputStream);
                        while ((in != null) && ((length = in.read(bbuf)) != -1)) {
                             op.write(bbuf, 0, length);
                        }

  • How to specify the download file name??

    Hi guys~~~
    I have servlet which can generate a *.pdf file,I found if I didn't setContentType="application/pdf",I can download it!!But the download file name is my servlet file name.If I want to change the download file name,How do I do????
    thanx a lot!!!Best regard!

    Thanx for ur help...But I encounter a new charllenge now...
    I use a javascript(window.open("/myservlet")) to open the download file servlet.
    Everything is okay.But when I finish downloading the file which window I opened cant close itself automatically.
    I am really not understand the header parameter of the HTML header,could someone give me something about this??
    Thanx again!!!!

  • Downloading files from a servlet...

    Everything is working except...
    The first problem we have run into during testing is that when two users click on the same file for downloading, the servlet locks up for one request while handling the second request. When the first request is finished, the second one carries on. Not a good thing with larger files, but, this is understandable due to servlets not being multi-threaded.
    We attempted to fix that problem by synchronizing the reading/writing of the file. A new problem arose, when both users download the file, one user gets a majority of the server bandwidth, while the other gets very little. (i.e. 400k per sec. vs. 40k per sec.)
    Does anyone have a suggestion on how to manipulate the resources to balance the download bandwidth equally amongst clients while still using the servlet.
    (Using servlets is a necessity due to the application design)

    Servlets not multi-threaded? Well, you can do some work to make them not multi-threaded, but by default they are multi-threaded. And I don't see why you would need to do any synchronization, either. Perhaps the problem lies in your servlet container. Most of them will create multiple threads that reference the same servlet, if they need to handle multiple requests. But I don't know how they handle load-balancing between requests.

  • What is wrong with the following Java servlet code that downloads files?

    Hi,
    I need urgent help.
    This is the issue. I have a JSP code that calls a Java servlet class. This class is used to download files from the JSP page. The following is the piece of code that does the file download.
    String pathOfFile = gsPath + "/" + gsFileName.substring(gsFileName.indexOf("~")+1);
    File F = new File(pathOfFile);
    res.setContentType("application/stream");
    res.setHeader("Content-Disposition", "attachment; filename=" +gsFileName.trim());
    This code works just fine with IE. However, when this is used with Netscape, the class name gets added to the original file name extension. For example, if the class name is 'FileRetriever' and the file being downloaded is originally named 'a.doc', the file gets a name of 'a.doc.FileRetriever' after download using Netscape or Mozilla.
    One way to solve this is by adding the appropriate file type in the MIME settings in browser preference. However, this not a permanent solution.
    Can somebody let me know the correct code to fix this issue?
    Thanks for your time.

    We loose control of the file name once we pass the original file name to the input stream. When our code instructs Netscape to write the file on the local disk using an output stream, that is when Netscape/Mozilla adds this additional extension to the original file. So, essentially, we do not know about this additional extension.
    Any ideas on how to resolve this?
    Thanks.

  • How to download  file with Save As dialog

    I am trying to download files with a Save As dialog, according to Jason Hunter's instructions in Jave Enterprise Best Practices.
    String filename = "content.txt";
    // set the headers
    res.setContentType( "application/x-download" );
    res.setHeader( "Content-Disposition", "attachment; filename=" + filename);
    // send the file
    OutputStream out = res.getOutputStream();
    returnFile( filename, out);
    The file content.txt is in the root directory of my webapp. But I get this stack:
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.io.FileNotFoundException: content.txt (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.(FileInputStream.java:64)
         at com.interwoven.cssdk.examples.servlets.FileDownloadServlet.returnFile(FileDownloadServlet.java:43)
         at com.interwoven.cssdk.examples.servlets.FileDownloadServlet.doGet(FileDownloadServlet.java:24)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:484)

    The root of the webservers changes from server to server and
    sometimes it depends on the path you run webserver exe.
    The best i have found to overcome this kind of problems is by
    using getResourceAstream() method which basically looks at classpath locations only, but still this has some problems like it should kept at the
    specified classpath becoz the getResourceAsStrem() method is not static
    method and it always associated with the class object and the file
    accessing also should be in the same package/classpath.
    by using getResourceastream you cannot look at other places (except classpaths)
    and this should be used only if you looking for .properites definitions.
    the Second best method is
    see you have a file called "context.txt" right
    before you create a file, first create a directory at the root, let say
    "\tmp"
    and then create a file \tmp\context.txt
    and then open an output stream to it either using fileoutputstreamm...
    and then write all output content to servlet/client output stream.
    this will be the best becoz you are specifying the "\" the root
    and this is common for all operating systems and definitely it will create at the root directory either serverroot or harddiskdrives root
    so you will never missout and the exceptin will also not comes along the way
    cheers..
    if you get new thing , let me know
    bye
    with regards
    Lokesh T.C

  • 500 Internal Server Error in Download File

    Help , i am creating one Download file Run Exception!! <BR>
    <HR>
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr bgcolor="#FFFFFF">
    <td align="left" colspan="3" height="48" style="font-size:14pt;color:#666666">500 &nbsp Internal Server Error</td>
    </tr>
    </table>
    <br>
    <div style="font-size:12pt;font-weight:bold">
    Failed to process request. Please contact your system administrator.
    </div>
    <br>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:12pt;font-weight:bold;color:#FFFFFF;background-color:#3F73A3;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Error Summary</td></tr></tbody></table>
    <p>While processing the current request, an exception occured which could not be handled by the application or the framework.
    <p>If the information contained on this page doesn't help you to find and correct the cause of the problem, please contact your system administrator.
    To facilitate analysis of the problem, keep a copy of this error page.
    Hint: Most browsers allow to select all content, copy it and then paste it into an empty document (e.g. email or simple text file).
    <p>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:8pt;font-weight:bold;color:#000000;background-color:#A1A1A1;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Root Cause</td></tr></tbody></table>
    The initial exception that caused the request to fail, was:<br>
    <br>
    <div style="font-size:8pt;color:#FF0000">  
    com.sap.tc.webdynpro.services.exceptions.PDFDocumentCreationException: ../../local/Call_RfcPrintGr/App/~wd_key2_1282096396526/Error+PDF.pdf?sap-wd-download=1&amp;sap-wd-dl_behaviour=1&amp;sap-wd-cltwndid=5e0b24a1aa6b11dfbd1b00215e736cac&amp;sap-wd-appwndid=5e0b24a2aa6b11dfa4c900215e736cac&amp;sap-wd-norefresh=X
    </div>
    <br>
        at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.InteractiveForm.afterHandleActionEvent(InteractiveForm.java:407)<br>
        at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.afterApplicationModification(ClientApplication.java:1132)<br>
        at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.afterApplicationModification(ClientComponent.java:895)<br>
        at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doRespond(WindowPhaseModel.java:573)<br>
        at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:152)<br>
        ... 25 more<br>
    <br>
    <p>See <a href="#exceptionchain">full exception chain</a> for details.
    <br>
    <br>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:12pt;font-weight:bold;color:#FFFFFF;background-color:#3F73A3;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Correction Hints</td></tr></tbody></table>

    <p>
    <b>PDF Document Render Exception.</b></br></br>Please check the following:<ul><li>Template file is not corrupted.</li><li>Data being passed is a vaild XML.</li><li>You have configured the web service client proxy properly.</li><li>Adobe Document Service (ADS) is configured properly (follow the configuration guide available at <a href="https://service.sap.com/instguides">SAP service market place</a> to check with all the supported configuration options).</li></ul></br>If the problem still persists, report it to us. We need the following information to investigate the problem further:<ul><li>Click <a href="../../local/Call_RfcPrintGr/App/~wd_key2_1282096396526/Error+PDF.pdf?sap-wd-download=1&sap-wd-dl_behaviour=1&sap-wd-cltwndid=5e0b24a1aa6b11dfbd1b00215e736cac&sap-wd-appwndid=5e0b24a2aa6b11dfa4c900215e736cac&sap-wd-norefresh=X"><b>here to download the error pdf</b></a> that has been generated instead of the actual pdf. This is an important document to analyse the problem further.</li><li>Follow the steps below to get the system information where web dynpro is running:<ul><li>Go to : http://host:port/sap/monitoring/SystemInfo</li><li>Log on as Administrator user.</li><li>Click on link <i>all components...</i> there. This will take you to the system information page that lists the version information of all the componenets installaed on your server.</li><li>Save this entire page (containing the version information of all the componenets installed on your server)</li></ul></li><li>Follow SAP notes mentioned below to get the trace files for web dynpro and ADS. Then run your application again. Get the <strong>latest updated</strong> trace files from the server. If webdynpro and ADS are not running on the same server, then you need to turn on the tracer for the respective servers:<ul><li>#742674 to turn on the web dynpro trace on the server where web dynpro is running.</li><li>#846610 to turn on the ADS trace on the server where ADS is running.</li></ul></li>
    <p><i>Note: the above hints are only a guess. They are automatically derived from the exception that occurred
    and therefore can't be guaranteed to address the original problem in all cases.</i>
    <br>
    <br>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:12pt;font-weight:bold;color:#FFFFFF;background-color:#3F73A3;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>System Environment</td></tr></tbody></table>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:8pt;font-weight:bold;color:#000000;background-color:#A1A1A1;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Client</td></tr></tbody></table>
    <table border="0" cellpadding="3" cellspacing="1" style="font-size:8pt;color:#333333;background-color:#DCE3EC;float:left;margin-bottom:2px"><tbody>
    <tbody><tr><td style="background-color:#FFFFFF">Web Dynpro Client Type</td><td style="background-color:#FFFFFF">HTML Client</td></tr>
    <tr><td style="background-color:#FFFFFF">User agent</td><td style="background-color:#FFFFFF">Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.126 Safari/533.4</td></tr>
    <tr><td style="background-color:#FFFFFF">Version</td><td style="background-color:#FFFFFF">null</td></tr>
    <tr><td style="background-color:#FFFFFF">DOM version</td><td style="background-color:#FFFFFF">null</td></tr>
    <tr><td style="background-color:#FFFFFF">Client Type</td><td style="background-color:#FFFFFF">safari</td></tr>
    <tr><td style="background-color:#FFFFFF">Client Type Profile</td><td style="background-color:#FFFFFF">nn7</td></tr>
    <tr><td style="background-color:#FFFFFF">ActiveX</td><td style="background-color:#FFFFFF">disabled</td></tr>
    <tr><td style="background-color:#FFFFFF">Cookies</td><td style="background-color:#FFFFFF">enabled</td></tr>
    <tr><td style="background-color:#FFFFFF">Frames</td><td style="background-color:#FFFFFF">enabled</td></tr>
    <tr><td style="background-color:#FFFFFF">Java Applets</td><td style="background-color:#FFFFFF">enabled</td></tr>
    <tr><td style="background-color:#FFFFFF">JavaScript</td><td style="background-color:#FFFFFF">enabled</td></tr>
    <tr><td style="background-color:#FFFFFF">Tables</td><td style="background-color:#FFFFFF">enabled</td></tr>
    <tr><td style="background-color:#FFFFFF">VB Script</td><td style="background-color:#FFFFFF">enabled</td></tr>
    </tbody></table>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:8pt;font-weight:bold;color:#000000;background-color:#A1A1A1;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Server</td></tr></tbody></table>
    <table border="0" cellpadding="3" cellspacing="1" style="font-size:8pt;color:#333333;background-color:#DCE3EC;float:left;margin-bottom:2px"><tbody>
    <tbody><tr><td style="background-color:#FFFFFF">Web Dynpro Runtime</td><td style="background-color:#FFFFFF">Vendor: SAP, build ID: 7.0104.20090324111057.0000 (release=NW701_04_REL, buildtime=2009-06-12:08:35:57[UTC], changelist=58858, host=pwdfm106), build date: Fri Aug 28 14:10:00 CST 2009</td></tr>
    <tr><td style="background-color:#FFFFFF">J2EE Engine</td><td style="background-color:#FFFFFF">7.01   PatchLevel 58805.</td></tr>
    <tr><td style="background-color:#FFFFFF">Java VM</td><td style="background-color:#FFFFFF">Java HotSpot(TM) 64-Bit Server VM, version:1.4.2_17-b06, vendor: Sun Microsystems Inc.</td></tr>
    <tr><td style="background-color:#FFFFFF">Operating system</td><td style="background-color:#FFFFFF">Windows 2003, version: 5.2, architecture: amd64</td></tr>
    </tbody></table>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:8pt;font-weight:bold;color:#000000;background-color:#A1A1A1;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Session &amp; Other</td></tr></tbody></table>
    <table border="0" cellpadding="3" cellspacing="1" style="font-size:8pt;color:#333333;background-color:#DCE3EC;float:left;margin-bottom:2px"><tbody>
    <tbody><tr><td style="background-color:#FFFFFF">Session Locale</td><td style="background-color:#FFFFFF">zh_TW</td></tr>
    <tr><td style="background-color:#FFFFFF">Time of Failure</td><td style="background-color:#FFFFFF">Wed Aug 18 09:53:16 CST 2010 (Java Time: 1282096396526)</td></tr>
    </tbody></table>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:8pt;font-weight:bold;color:#000000;background-color:#A1A1A1;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Web Dynpro Code Generation Infos</td></tr></tbody></table>
    <table border="0" cellpadding="3" cellspacing="1" style="font-size:8pt;color:#333333;background-color:#DCE3EC;float:left;margin-bottom:2px"><tbody><thead><tr><td colspan="2">local/Call_RfcPrintGr</td></tr></thead>
    <tbody><tr><td style="background-color:#FFFFFF">SapDictionaryGenerationCore</td><td style="background-color:#FFFFFF">7.0017.20061002105236.0000 (release=645_VAL_REL, buildtime=2008-09-17:13:01:31[UTC], changelist=419377, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapDictionaryGenerationTemplates</td><td style="background-color:#FFFFFF">(unknown)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapGenerationFrameworkCore</td><td style="background-color:#FFFFFF">7.0017.20060719095755.0000 (release=645_VAL_REL, buildtime=2008-09-17:12:48:53[UTC], changelist=411255, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapIdeWebDynproCheckLayer</td><td style="background-color:#FFFFFF">7.0017.20080801093115.0000 (release=645_VAL_REL, buildtime=2008-09-17:13:07:06[UTC], changelist=495367, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapMetamodelCommon</td><td style="background-color:#FFFFFF">7.0017.20061002105432.0000 (release=645_VAL_REL, buildtime=2008-09-17:12:49:40[UTC], changelist=419384, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapMetamodelCore</td><td style="background-color:#FFFFFF">7.0017.20061002105432.0000 (release=645_VAL_REL, buildtime=2008-09-17:12:49:34[UTC], changelist=419384, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapMetamodelDictionary</td><td style="background-color:#FFFFFF">7.0017.20060719095619.0000 (release=645_VAL_REL, buildtime=2008-09-17:12:58:48[UTC], changelist=411251, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapMetamodelWebDynpro</td><td style="background-color:#FFFFFF">7.0017.20080801093120.0000 (release=645_VAL_REL, buildtime=2008-09-17:13:03:59[UTC], changelist=495368, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapWebDynproGenerationCTemplates</td><td style="background-color:#FFFFFF">7.0017.20080829103545.0000 (release=645_VAL_REL, buildtime=2008-09-17:13:16:41[UTC], changelist=499141, host=pwdfm101)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapWebDynproGenerationCore</td><td style="background-color:#FFFFFF">7.0017.20080801093115.0000 (release=645_VAL_REL, buildtime=2008-09-17:13:07:12[UTC], changelist=495367, host=PWDFM101.wdf.sap.corp)</td></tr>
    <tr><td style="background-color:#FFFFFF">SapWebDynproGenerationTemplates</td><td style="background-color:#FFFFFF">7.0017.20080829103545.0000 (release=645_VAL_REL, buildtime=2008-09-17:13:16:41[UTC], changelist=499141, host=pwdfm101)</td></tr>
    </tbody></table>
    <table border="0" cellpadding="3" cellspacing="1" style="font-size:8pt;color:#333333;background-color:#DCE3EC;float:left;margin-bottom:2px"><tbody><thead><tr><td colspan="2">sap.com/tcwddispwda</td></tr></thead>
    <tbody><tr><td style="background-color:#FFFFFF">No information available</td><td style="background-color:#FFFFFF">null</td></tr>
    </tbody></table>
    <table border="0" cellpadding="3" cellspacing="1" style="font-size:8pt;color:#333333;background-color:#DCE3EC;float:left;margin-bottom:2px"><tbody><thead><tr><td colspan="2">sap.com/tcwdcorecomp</td></tr></thead>
    <tbody><tr><td style="background-color:#FFFFFF">No information available</td><td style="background-color:#FFFFFF">null</td></tr>
    </tbody></table>
    <br>
    <br>
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:12pt;font-weight:bold;color:#FFFFFF;background-color:#3F73A3;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Detailed Error Information</td></tr></tbody></table>
    <a name="exceptionchain">
    <table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size:8pt;font-weight:bold;color:#000000;background-color:#A1A1A1;padding-left:6px;clear:left;margin-bottom:2px;"><tbody><tr><td>Detailed Exception Chain</td></tr></tbody></table>
    </a>
    <pre>
    com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.base.core.PDFDocumentRuntimeException: Failed to  UPDATEDATAINPDF
         at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.InteractiveForm.afterHandleActionEvent(InteractiveForm.java:420)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.afterApplicationModification(ClientApplication.java:1132)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.afterApplicationModification(ClientComponent.java:895)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doRespond(WindowPhaseModel.java:573)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:152)
         at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    Caused by: com.sap.tc.webdynpro.services.exceptions.PDFDocumentCreationException: ../../local/Call_RfcPrintGr/App/~wd_key2_1282096396526/Error+PDF.pdf?sap-wd-download=1&amp;sap-wd-dl_behaviour=1&amp;sap-wd-cltwndid=5e0b24a1aa6b11dfbd1b00215e736cac&amp;sap-wd-appwndid=5e0b24a2aa6b11dfa4c900215e736cac&amp;sap-wd-norefresh=X
         at com.sap.tc.webdynpro.clientserver.uielib.adobe.impl.InteractiveForm.afterHandleActionEvent(InteractiveForm.java:407)
         ... 29 more
    </pre>
    </div>
    </div>

  • Downloading files from a browser

    I need to write an app that will download files from our clients and put it on our server. It is client initiated process from a browser.
    I know the html type is "type=file" and when the user clicks it it brings up a file dialog. Then they can select a file name from their hard drive.
    Now, when the user hits "submit" I want the file to download to our server. But how can I get an http servlet to control this process?

    First of all, download is when data comes from somewhere to your local machine, Upload is when you send data from your local machine to somehwere. So, you are looking to UPLOAD data.
    Second, if you search on here for references to 'upload', you will find exactly what you are looking for.

  • Problem downloading from servlet in WLS6

    A servlet running in WLS6 is used for downloading files. When the file is
              selected in IE5 the dialog asking what to do with the file (open from
              current location/save) opens. If the file is small enough the service
              request is handled (file written to ServletOuputStream and stream flushed &
              closed) at the servlet side BEFORE a selection in this dialog is even made!
              So if the user selects cancel from the first dialog when the actual download
              has not even started, then it seems at the server side that the user
              downloaded the file.
              How can I change this behaviour so that nothing is written in to the
              ServletOutputStream until the client is actually receiving? I have tried to
              modify buffer size and flush all the time without success!
              

    Hi Gareth,
    I don't think it's possible to donwload classes from R/3 to CRM. It was possible between CRM 2.0c & R/3, but was deactivated as a standard functionality because the data models for classes in the two systems are to different.
    What kind of classification data would you like to download?
    Kind regards,
    Michaael.

  • Multiple download with servlet

    Hi! I have a web app in struts where users can upload and download files from it. Now, the upload part is finished. My problem is the download part. I want it to be able to handle multiple downloads. The browser(client) sends a list of fileIDs to the server. The server looks for the files in its local directory, reads them, and streams them to the outputstream of HttpServletResponse (to the client). But only the first file ever gets sent. Here's part of my code:
    files is a String[] which contains the list of fileIDs the user wants to download
    FileDetails is a class I made which merely holds a File object, and its size
    try {                                           
         DataOutputStream dos = new DataOutputStream( response.getOutputStream() );
         for( int i = 0; i < files.length; i++ ) {
              response.setHeader("Content-disposition",
                               "attachment; filename" +
                               files[i] );
              //get file
              FileDetails fd = fileManager.getFile( Integer.parseInt(files) );          
              response.setContentType( "application/Octet-stream" );
              //read file
              DataInputStream dis = new DataInputStream( new FileInputStream(fd.getFile()) );
              byte[] contents = new byte[ fd.getSize() ];     
              dis.read( contents, 0, fd.getSize() );
              dos.write( contents, 0, fd.getSize() );
              dos.flush();                                                                                                                                                           
    } catch( Exception e ) {
         System.out.println( e );
    How do I make it send multiple files to the user? Also, response.setHeader doesn't seem to set the default filename. For example, if I download pics.jpeg, I get a dialog box with mywebpage.do(i'm using struts) as the default filename.
    Your help would be greatly appreciated! =)

    you could try a refresh to see if it works
    when user first access servlet, get all files and store them
    in a session.
    then send the first file normally and set the browser to refresh
    at a certain time.
    when the browser calls the servlet again, send the next
    file, repeat until all files have been sent.

  • Session making triouble while downloading files successively

    hi, i m hving some problems with file downloading.... my code that saves bytes array into the session is as follows
    byte[] bytes = proposalService.getDownload(fileName); // a method that returns bytes array
                Object bt = request.getSession(false).getAttribute("bytes");
                if(bt != null){
                    request.getSession(false).setAttribute("bytes", null);
                    request.getSession(false).removeAttribute("bytes");
                request.getSession(false).setAttribute("bytes", bytes);
                bytes = null;
                try {
                    response.sendRedirect("FileDownload");
                } catch (IOException ex) {
                    ex.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }and the servlet that gets the data from session are able to download
    StringBuffer xlsFile = null;
            HttpSession session = null;
            StringBuffer xlsFileHeader = null;
            try {
                xlsFile = new StringBuffer();
                xlsFile.append("MI_Tariff"+new Date().getTime());
                xlsFile.append(".xls");
                response.setHeader("Cache-Control", "max-age=30");
                response.setContentType("application/xls");
                xlsFileHeader = new StringBuffer();
                xlsFileHeader.append("attachment; filename="+xlsFile);
                response.setHeader("Content-disposition", xlsFileHeader.toString());
                session = request.getSession(false);
                byte[] bytes = (byte[]) session.getAttribute("bytes");
                System.out.println("----------------------------"+bytes.length);
                if(bytes !=null && bytes.length > 0) {
                    response.setContentLength(bytes.length);
                    ServletOutputStream servletOutputStream = response.getOutputStream();
                    servletOutputStream.write(bytes, 0, bytes.length);
                bytes = null;
            } catch(Exception e){
                e.printStackTrace();
            } finally{
                session.setAttribute("bytes",null);
                session.removeAttribute("bytes");
                xlsFile = null;
                xlsFileHeader = null;
            }the problem is i m using this code to download 3 files one by one ... some times it returns the proper file that i want to download but sometime last downloaded file is again downloaded....
    i debug this code thoroughlly each time new file is fetched and stored in to the session but when the servlet code runs there might be some problems due to which the bytes array remains empty and it returns the last file downloaded....
    as u can see bytes are being removed proporly but i think the problem is with session ... it might use diffrent session for retrieving and saving the bytes array.. HOW CAN I SOLVE THIS PROBLEM....
    All the suggestions are eagerly welcomed
    Thanks in advance

    Just realized that I forgot to give the link to the file servlet earlier; take a look at this code:
    http://balusc.blogspot.com/2007/07/fileservlet.html
    And no, sorry if you thought that was for you personally; I try to put that in every post of mine so that at least some of the new users go and take a look. If you look at most posts on the forums, there are a lot of replies asking the posters to:
    - use code tags
    - use proper language ( i.e.complete words and not 'u' , 'plz' etc )
    - give the problem details clearly
    - give stack traces
    etc.
    Since this resource is already available, I put this up with my posts instead of repeating the same things 50 times a day. It's like a pseudo-signature :)
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • HTML tag to upload and Download files

    hello all
    IS there any HtTML tag to upload and download files ???
    rgds
    ASHWIN

    Yea, for downloading you can use a normal link. For uploading, you need an html form like
    <form name="form1" enctype="multipart/form-data" method="post" action="doSomething.jsp">
      <input type="file" name="file">
    </form>To be honest I know nothing about jsp and servlets yet, but I would guess that it works just the same as with php, with which I am alot more familiar. Basicly, the form tag with the input type="file" tag tells the form to submit your file to the webserver.
    Then, whatever script you call with action="anythingYouWantHere" will handle the file the user submitted. There must be very similar functions to handle them in java than there is in php.
    Things to look for with file upload that often are buggy is the permissions / security settings you have on your webserver. Sometimes you need to make a special folder with extra permissions to allow you upload to work.
    Thats about all I know on this matter, good luck :)

  • Help required with downloading files from inside WEB-INF folder

    I am working on a web application and I have an upload script which uploads different files to a foler called 'uploads' . To stop users from accessing the folder content I have put it in the /WEB-INF/.
    In my JSP file, I used to link to the uploaded files like this before for users to download them :
    if(filesListIterator.hasNext()
    files = (FilesBean)filesListIterator.next();
    <tr><td><a target="_new" href="<%=files.getFileName()%>">"<%=files.getFileName()%></a></td></tr>
    }I need to know how to alter the above link to make it access/download files from the /WEB-INF/uploads/ while still restricting direct access to the files.
    Thanks
    Message was edited by:
    topiwal

    Anything under WEB-INF is not directly accessible via the browser/ client. You could try defining the JSP/ Servlet inside web.xml deployment descriptor and see if you can access the file from there.
    I think a better way to accomplish this would be to keep the file outside WEB-INF , and use other techniques to protect the folder that contains the file - for example password-protection, or defining a .htaccess file and serving a 403 Forbidden error.

  • Download files through web Dynpro

    Hai All,
      Now i am working in web Dynpro2.0.9. "IWDResource" property is used to download and upload files in web Dynpro. "IWDResource" is not supported by web Dynpro2.0.9.what is the alternative way for to download files other than using "IWDResource" property.If you have sample codings send it.
    Thanks in Advance,
    s.v.selva Bala.

    Hallo Anilkumar,
    read my tutorial on Uploading/Downloading Files in Web Dynpro NW04:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d2201c20-0801-0010-49b3-94fca8f590d5">Uploading and Downloading Files (39)</a>
    You are right, that the new on-demand-stream concept based on the IWDResource-API (Resource Simple Type) is not applicable in NW04.
    Regards, Bertram

  • How can I upload and download files with uiXML?

    I want to implement upload and download files with uiXML. In some previouse topic I got answare to look in AbstractPageBroker class in JavaDOC. I did it but this is a very-very little resolution description for this problem. I think for developers YOU (UIX Team) must in very quick time to put some examples on the NET because this is a nice technology but with adecvate samplase and developers guide it will be dead very soon. I digging this forum for information. I see many many people have same problems about this technology. They like it and want to use and try but documentation is very very poor.
    WE WANT EXAMPLES and separate forum for UIX. I think it deserve this.
    If You have any more detailed documentation would be nice to put on the net. I have uixdemo.zip file but this is in very early fase of development. I downloaded it before fwe months. And now I can't find it anymore on youre site. What happend?

    Attila -
    I went back and re-read the JavaDoc for AbstractPageBroker and MultipartFormItem and put together the following sample PageBroker based on the description from the JavaDoc:
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.share.util.MultipartFormItem;
    import oracle.cabo.servlet.xml.UIXPageBroker;
    * An extension of UIXPageBroker which stores all uploaded
    * files in the temporary directory.
    public class UploadingPageBroker extends UIXPageBroker
    * Override of AbstractPageBroker.doUploadFile() which saves
    * all files to the temporary directory.
    protected String doUploadFile(
    BajaContext context,
    Page page,
    MultipartFormItem item) throws IOException
    // Get the location of the file to create in the temp directory.
    // Of course a real application probably wouldn't upload files to
    // the temp directory - just using this contrived example to
    // demonstrate basic uploading support.
    File file = _getFile(context, item);
    if (file != null)
    // Create a FileOutputStream. Of course, a real application would
    // probably want to buffer the output
    FileOutputStream out = new FileOutputStream(file);
    // Write out the file
    item.writeFile(out);
    // Close up the output stream
    out.close();
    // We can return a value here to add to the PageEvent
    // if so desired.
    return null;
    // Gets the File for the item that we are uploading
    private File _getFile(
    BajaContext context,
    MultipartFormItem item
    // Get the file name
    String name = item.getFilename();
    // If we don't have a file, bail...
    if (name == null)
    return null;
    // Get the path to the temporary directory
    File dir = _getTempDir();
    // Return the File object
    return new File(dir, name);
    // Returns the path to the temprary directory
    private File _getTempDir()
    // Get the temporary directory from the ServletContext
    ServletConfig sConfig = getServlet().getServletConfig();
    ServletContext sContext = sConfig.getServletContext();
    return (File)sContext.getAttribute("javax.servlet.context.tempdir");
    In this sample, each uploaded file is simply saved in the temporary directory. You'll want to replace the code that creates the FileOutputStream for the uploaded file to use whatever OutputStream makes sense for your application.
    BTW - I used the following UIX page to test this out:
    <?xml version="1.0" encoding="UTF-8"?>
    <page xmlns="http://xmlns.oracle.com/uix/controller">
    <content>
    <pageLayout xmlns="http://xmlns.oracle.com/uix/ui">
    <contents>
    <form name="uploadForm" usesUpload="true">
    <contents>
    <fileUpload name="uploadedFile"/>
    <submitButton name="upload" text="Upload"/>
    </contents>
    </form>
    </contents>
    </pageLayout>
    </content>
    </page>
    Hope this sample helps with the uploading part of your question. I'll see if I can provide a download sample in a later post.

Maybe you are looking for