Jsp file download problem

Hi,
I am using following code in jsp.
<%@ page session="true"%>
<%@ page import="java.io.*" %>
<%
String fileName="test.txt";
response.setContentType("application/txt");
response.setHeader("Content-Disposition","attachment; filename="+fileName);
try
PrintWriter fw = response.getWriter();
fw.write("param1");
fw.write(",");
fw.write("param2");
fw.write(",");
fw.write("param3");
fw.write("\r\n");
fw.flush();
fw.close();
catch(Exception e)
%>
<input type=button value="CONTINUE">
The problem is flow does not go to CONTINUE button and it lost the control after response.setHeader("Content-Disposition","attachment; filename="+fileName);
Do you have any idea what is the problem ?
Thanks

Hi
I am trying to give user option so that he can download a file in his local machine.
As you suggest use out object. I used the out object but i still have the same problem.
After writig in a data.csv file, control does not go to the CONTINUE button.
following is the sample code which i am using.
<html>
<body>
<%
String file="data.csv";
//response.setContentType("application/vnd.ms-excel");
response.setContentType("application/html");
response.setHeader("Content-Disposition","attachment; filename="+file);
try
out.write("Test1");
catch(Exception e)
%>
<div align="right">
<input type=button value="CONTINUE">
</div>
</body>
</html>
do you have any suggestion to fix this problem?
Kind Regards

Similar Messages

  • Questions regarding jsp file download from blob

    Hi developers, i'm doing jsp file download from a blob column in DB2 using struts,
    1) How do i design the jsp page such that the page will show perhaps a hyperlink for me to download the file?
    2) What about struts-config.xml? Do i need to modify any mappings there?
    It would be great if some kind developers were to provide some sample codes for me. Thanks alot. Your effort is kindly appreciated.

    http://kr.forums.oracle.com/forums/thread.jspa?threadID=1982213 - looks similar, you may need to change contentType as per use case

  • Jsp files download message!!! URGENT

    Hi,
    Does anyone have an idea about why I'm getting a download message when I try to run my jsp file deployed on OC4J?
    Seems to be a problem with parameters:
    This is what I do in my code:
    pageContext.forward("pag_loginc.jsp?p_idusr=" + strUsr + "&c_password=");
    And then I get a window for saving pag_loginc.jsp

    Yes,
    Works just fine. Which gui were you talking about. I did it through the webui.
    Check out the ora iFS User's Guide. pp 3-10 to 3-14.
    Good luck.

  • Unwanted JSP files downloaded to desktop

    When I delete spam mail at yahoo.com, I get a JSP 400 X 600 icon downloaded on my desktop.
    Now, common internet address's (amazon.com) simply download a similiar icon on the desktop and when clicked on I don't get a internet page that I can use, but this: user/doughoover/desktop/amazon.com
    What can I turn off (or on) to stop the safari problem ?
    The yahoo mail may be a seperate problem.
    Thanks for the help. I searched the archives, but could not find a topic.

    Hi,
    We are also facing the same problem. We did little digging and found the relation with <jsp:include> tag.
    We have <jsp:include> tag with FLUSH property set to "TRUE".
    <jsp:include page="xyz.jsp" flush="true"/> and we have a Compression filter given by Oracle Support(that code is same as the one available in Orion (http://www.orionserver.com/tutorials/filters/5.html).
    If we enable Compression and try to access the page, we do get "File Download" dialog box, warning "some files can harm..." and with "open", "save", and "cancel" button.
    This should have given the executed page. We tried to work with removing compression, then it works. We tried to modify the "FLUSH" property to "FALSE", then it works fine even with Compression on.
    Since we need compression(basic requirement) and also we cannot change the code(TRUE to FALSE), can any one gives any idea what's happening with 9.0.3. Since the same code with compression is working fine in OC4J 1.0.2.2.
    Any help is greatly appreciated.
    Regards
    Arun

  • File download problem

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

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

  • PDF Report file download problem

    Hi,
    I am using ApEx 3.1 and Oracle 10g and XSL-FO
    I have a problem in downloading a PDF file:
    (1) I have a report query (produced an xml file), report template, and report layout.
    After I linked the new PDF report into my application, when I click on the button, the PDF “File Download” popup shows only two buttons (“save” and “cancel”) with a warning message “The file you are downloading cannot be opened by the default program. It is either corrupted or it has an incorrect file type. As a security precaution, it is recommended that you cancel the download”, and the file name shows up as “f.pdf”. I am able to open the saved file (f.pdf) in Adobe Acrobat and it looks fine.
    (2) In “Home>Application Builder>Application xxx >Shared Components>Report Queries>Edit Report Query”, when I click on the “Test Report” button, the “File Download” popup shows with all three buttons, (“open”, “save”, “cancel”) --- it shows the correct name of the file, and, no warning message! At this point, the file can be opened with the “open” button”, or, be saved to the disk. The saved file opens with Adobe Acrobat and the contents are identical to that of the file “f.pdf”.
    (3) I created another application (within the same workspace) with just one page, linked the PDF report in this application, and clicked on the button, and got the same response as in (2).
    It looks like I could try to create a new application by copying page by page from the application quoted in (1), and see if that would solve the problem. It is time consuming, the outcome is uncertain, and also could create some other problems
    What could be the cause of this problem? Any alternatives? I would appreciate any help.
    Thanks
    Vasan

    We experienced the exact same problem as the OP (including corrupt files named "f.pdf" and the browser dialog box he documented). Don't know if his environment is similar, but here is how we fixed our issue:
    Our app uses an Authentication Scheme that includes under "Page Session Management" a "Session Verify Function" called like this: "return timeout_pkg.check_timeout;". This timeout_pkg I think came from code originally posted here, it works well so thanks to the original coder. However it does present a small issue in that it rewrites the mime headers in the server response in one use case. Since it is rewriting the headers to "text/html" even though we are sending back a report where the mime header should be "application/pdf", the client gets confused and the result is the symptoms the OP posted.
    So if we change the timeout package and body so the signature is like this: "function check_timeout (p_request IN VARCHAR2 DEFAULT null) return boolean;"
    And change the call in the "Session Verify Function" to pass the request as a parameter like: "return timeout_pkg.check_timeout(:REQUEST);"
    And change the body of the timeout_pkg.check_timeout function to use the correct mime type when calling a report:
    elsif not g_cookie_already_sent then
    if (p_request is not null and INSTR(p_request, 'PRINT_REPORT') != 0) then
    owa_util.mime_header('application/pdf', FALSE);
    else
         owa_util.mime_header('text/html', FALSE);
         end if;
    then we solve our particular problem... I hope this saves somebody else some time, remember this was our specific solution to the exact symptoms documented by the OP, however as a general rule I would say if you are experiencing problems with pdf printing from Apex, watch out for anything your app might be doing with the owa_util pkg in particular and mime headers in the server response in general.
    Edited by: cmcneil on Sep 5, 2008 11:45 AM
    Edited by: cmcneil on Sep 5, 2008 11:59 AM

  • Blob file download problem

    Hi Everyone,
    I can upload a microsoft word document using file browser and store it in oracle database table as a blob.
    Now when I try to display this word document. I am getting strange characters in the browser instead of a file download dialog box.
    Here is the code
    owa_util.mime_header('application/msword', false);
    htp.p('Content-Disposition: attachment; filename="test.doc"');
    owa_util.http_header_close;
    wpg_docload.download_file(lob_loc);
    I want it to popup a file download box. What am I missing?
    I tried with PDF, in IE it pops up the file download box but in Firefox, it prints the binary data in the browser.

    not sure if this is the problem, I noticed you are missing the init. This is what I use to show pdfs:
      htp.init;
      owa_util.mime_header('application/pdf',false);
      htp.print('Content-Length: ' || dbms_lob.getlength(b));
      htp.print('Content-disposition: inline; filename="pdf.pdf"');
      owa_util.http_header_close;
    wpg_docload.download_file(b);

  • .JAD/JAR file download problems

    Hi,
    I'm having trouble with downloads of .jad and .jar files through WAP onto my mobile phone. The .JAR file downloads fine via the WAP APN but then the .JAD file doesn't download.
    From what I can see, it looks like the j2me app manager on the phone which reads the jad file tries to download the .JAR file directly from the website. The problem here is that since i'm connected to a WAP APN, i have to download through the proxy so there's no direct access to the internet.
    Anyone else have this kind of problem?
    Is is possible to set up the .JAD file somehow so that it downloads through a proxy or takes the current APN to download it??
    This is a HTTPS site but I dont think that would make a difference.
    Cheers,

    Hello,
    I have a very similar problem. Not quite the same tho: i am able to download the JAD and the JAR gets requested. One some phones the JAR gets downloaded properly but on others it blocks after 50 or 60 %.
    We only encounter this problem when downloading through a proxy (defined in the phones wap/internet configuration); when we connect without a proxy everythibng works just fine.
    Another clue might be the fact that we cannot do HTTPS communication (from the device) using a connection that is proxied. (We tested by putting the file on the device using bluetooth).
    Has anybody seen this before? Do you know a solution to this problem?
    Thank you,
    Nick

  • Jar files download problems in Java Webstart with JRE 1.6

    We have encountered a few problems in Java Webstart with JRE 1.6
    In JRE 1.5, the jar files are getting downloaded onto the client
    machine with it's original names.
    Example :
    Server File Name : acm.jar
    Client File Name : RMacm.jar
    But in JRE 1.6, the jar files are getting downloaded with improper file names.
    Example :
    Server File Name : acm.jar
    Client File Name : 4fb074cc-66fc7407
    Moreover the path itself seems to be invalid.
    Example Path :
    JRE 1.5 path:
    C:\Documents and Settings\Administrator\Application
    Data\Sun\Java\Deployment\cache\javaws\https\D17.16.23.11\P443\DMtest\DMwebStart
    JRE 1.6 path:
    C:\Documents and Settings\Administrator\Application
    Data\Sun\Java\Deployment\cache\6.0\12
    Due to this, we are facing Classpath problems.
    What changes do we have to make to the code, for Java
    Webstart to work ?
    We are using JBoss 4.0.4 and JDK 1.5 in the Server
    On the client machine, we have IE 6 and JRE 1.6.01
    Help would be appreciated.

    Ask your Java Web Start question at:
    http://forum.java.sun.com/forum.jspa?forumID=38

  • Camera Raw file download problem

    Downloaded Camera RAW Images recognised in PS5 Bridge prior to download (thumbnails visible) but after download, no thumbnails visible, only icons, which when double clicked, the following error message appears "Could not complete your request because Photoshop does not recognize this type of file".
    Other previously downloaded files can be opened, and a test picture I just took, downloaded and opened up fine. Looking at the files that won't open, I noticed that the metadata is missing, so I am wondering if during the download process, the files somehow became corrupted. Can any one help with this problem please? Thanks.

    The files were the correct size after downloaded them and I used the PS5 Bridge program to dowload directly from my camera.  I have spoken to Nikon and Adobe about this problem and both seem to agree that the files became corrupted during the download process.  Nikon suggested using third party software to recover the files from the SIM card, which I have now done, but out of 120 files, there were still 6 or 8 files that I couldn't do anything with.  the strange thing is that I could view all the files with the Nikon NX2 software, but as soon as I tried to do anything with them, like converting them to a jpg, I got a meaasage saying that the file was not recognised!   So panic over for this particular issue, but I am still curious to know if this is a common problem.  I suppose if nothing else, I have learned a valuable lesson, which is not to delete pictures from the camaera until after they have been successfully transfered to the computer.  Thanks for your interest in my tail of woe!

  • Pdf file download problems

    I use the Adobe Creative Cloud file storage system to store and also share pdf files with my customers. When I need to share a pdf file, I create a link for the folder containing the correct pdf files. Then I paste the link to that folder into the body of an email that I then send to the customer. Often I will paste several different links into the same email. Normally, when a customer downloads, they simply click on the link, then they are directed to the folder contents. They then click on each individual file within the folder...on the next page there is a download drop down menu button at the left of the screen.....the dropdown menu normally give 3 or 4 options to download as: PDF, jpg, png and ease. For some reason the last week, at least 50% or more of my customers are not able to download.... they are telling me that the drop down menu does not give them the pdf option. I talked with Adobe customer support but the lady didn't seem to have the foggiest idea why this was happening or how to fix it...she said she would look into a solution and call me back but she never did. This happened about a month ago too and the problem seemed to correct itself a day or two later.... and again no one at Adobe could tell me what was up or how to fix the problem. Anyone out there experienced anything like this? Or maybe I am the only one using this service to share PDF files?

    Having the exact same problem, really frustrating. It's not working with new files I put up on the Cloud and even the files that were working previously are not downloadable as PDFs. I think Adobe has broken something…oddly when I'm logged in with my account, the download as PDF option is there, if I log out and try to get the file, then it's not there. I even tried to create another Adobe account and it's not possible to download when logged in using that account either.
    I wish that the Cloud sync and sharing worked more reliably, but it's frequently down, not working completely, not building previews etc.
    Really frustrating.

  • Azureus file download problems....

    Hi there, im pretty new to torrents so im sorry if this is an easy problem to rectify- as i said, im pretty new to it all so bare with me...
    Ok, so i have Azureus V 3.006 (the blue frog:P)
    Anyway up in till this morning it was working fine, i would search for torrents, click download and I would get the blue frog popup telling me they had been added to my azureus downloads, and that was that. couldnt be made simpler for simpletions like me.
    So today i found a file of interest and i clicked download, no frog. Now what i get is a popup box prompting me to save this torrent (which comes up as file unknown) to a directory. Basically i end up with a file which i dont know what the hell to do with...
    I dont know why it has reverted to this instead of just adding instantly to my list.
    Any help would be most appreciated ok.
    thanks

    Do this. After you download the file open Azureus then File->Open_>Torrent File  when the menu pops up click Add Files browse to where you downloaded the file(probably on your desktop) and add it. Then click OK.   btw   /home/"username"/Desktop is where your desktop is
    Last edited by raven3x7 (2007-03-16 21:01:17)

  • Japanese file download problem

    Hi
    I am using Weblogic Server 8.1
    I have file upload/download facility in my webapplication. While trying to download file with japanese filename , file name becomes junk
    The whole code bunch is working fine with weblogic 6.1
    Any ideas ??
    Regards
    Imran

    Hi Sandra
    Please find the detailed information for your questions.
    1.Internal table content before download:During Debugging,it was observed that internal table content was same in both versions.For testing,i used only brand new data(Transaction entry).
    2.Download with code Page conversion:Yes,codepage parameter 4103 was explicitly passed into GUI_DOWNLOAD Function module.Also the front end code page which is used by system is 4110 . No errors occured.
    3.System is an Unicode system only.
    4.Actually this 6 character does not refer the byte value,only the gap between 2 fields data is getting referred in ECC 6.0.Please find the below example.
    Example - File data after Download:
    ECC 6.0: Field1            Field2      (gap - 6 characters space between 2 fields data)  Using GUI_Download
    data       u0152©Ïu201Dԍu2020      EN                               
         4.6C: Field1            Field2       (gap - 2 characters space between 2 fields data) Using WS_Download
         data    u0152©Ïu201Dԍu2020  EN    
    Note:Special characters are Japanese characters:

  • SAP Netweaver CE 7.1 File Download Problem

    Hi
    Could you please help me out with link for the CE download,since the developer studio download file seems to have got corrupted.
    I tried downloading it from the following page:-
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/907cf403-dffb-2910-2595-93635948329a [original link is broken]
    Regards
    Navneet

    Hi Rajesh,
    What is the extension of the file you downloaded? Is it tar.gz or tar? Check the downloaded file size and compare them with the actual download size. See if it matches. Also try to extract the contents of the download using WInRAR http://www.rarlab.com/rar/wrar371.exe
    Madhu

  • File downloading problem: urgent

    hai ! I want to download a attached file from mail.
    If i use the following code i can get the file but
    i can't get the content of file.
    following is my code
    try
              part = multipart.getBodyPart(aid);
              contenttype=part.getContentType();
              fileName=part.getFileName();
              byte[] bytes=fileName.getBytes();
                 response.setContentType(contenttype);
                 response.addHeader("Content-Length",Integer.toString(bytes.length) );
                         response.addHeader("Content-Disposition", "attachment;filename="+fileName);
                        ServletOutputStream out=response.getOutputStream();
            out.write(bytes);
                        catch (MessagingException e) {
               e.printStackTrace();
              }

    The answer is in the JavaMail FAQ.

Maybe you are looking for