To download a file through JSP

I have a JSP page on which there is a Button, when clicking this button it must open a new browser window with "save file as" dialog.
How can i do this in JSP. Note that the user cant see or find the diretory in which files are stored.
I have seen that in ASP it is possible . is it possible in JSP .
renjith

Many file types are causing a download by simply linking them: http://..../sample.exe Others may be saved by "save as".

Similar Messages

  • Generating pdf file through jsp/servlet

    One of the MIME types for servlets/JSP response is "application/pdf".
    After setting Content-Type header "application/pdf" in servlet by
    setContentType() method, I am unable to get the output in a pdf file.
    Please let me know how I can generate a pdf file through Servelt/JSP
    response.
    Thanks.

    We've got a product which allows you to convert XML to PDF from a JSP. It doesn't currently take straight HTML, but the XML syntax we use is pretty similar (you can use CSS2 and so on), so for many pages it doesn't take a lot of conversion.
    If you check out http://big.faceless.org/products/report/examples.jsp you'll see a few examples, two of which are dynamically run from a JSP. There's a free trial download for you to test with (although it's a commercial product).
    Hope that helps.
    Cheers... Mike
    Mike Bremford - CTO mike at big.faceless.org
    Big Faceless Organization http://big.faceless.org

  • Adobe Reader 9.0 has delay when downloading PDF file through proxy server

    There is an issue with the Adobe Reader (and Acrobat) 9.0 PDF Link Helper ActiveX control for Internet Explorer (6 or 7) on Windows computers with respect to proxy servers. Due to this issue, there is a 2 minute delay for any Internet Explorer web browser on the Deere network before any PDF file will open from the Internet within the IE web browser if In-Place activation (Display PDF in Browser) is enabled in Adobe Reader 9. This problem does not affect Adobe Reader 8.
    What we are seeing is that when someone on the Deere network clicks on a links to a PDF file in the Internet, the PDF file downloads immediately. But then, after the PDF file is downloaded, the Adobe Reader 9 PDF Link Helper ActiveX control tries to talk directly to the Internet web site. The Adobe Reader 9 PDF Link Helper ActiveX control does not know how to negotiate our proxy server. So after a minute or two, the Adobe Reader 9 PDF Link Helper ActiveX control times out (gives up) and allows the IE browser to display the downloaded PDF file in the IE browser.
    We work around this issue by disabling In Place Activation for PDF files in IE (uncheck Display PDF in Browser). But we would like a fix for the PDF Link Helper ActiveX control.
    [HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\9.0\Originals]
    "bBrowserIntegration"=dword:00000000
    [HKEY_CURRENT_USER\Software\Adobe\Adobe Acrobat\9.0\Originals]
    "bBrowserIntegration"=dword:00000000
    Here's what our proxy people see when they do a trace of a PDF file download through their proxy server with IE 7 and Adobe Reader 9 with Display PDF in Browser checked.
    The browser tells the proxy to download the pdf, it does and sends it to the browser. Before the browser opens it something in Acrobat ( or I.E. ? ) tries to make a connection back to the content server that hosted the pdf. Unfortunately this agent does not ask the proxy to make the request for it, but rather asks local DNS to resolve the Internet server name. This request dies because our internal private network does not know anything about the Internet. Only the DNS used by the proxy can resolve Interent names. After two unsuccessful DNS queries into the private network, the agent tries to resolve the same Internet name with NBNS ( netbios name service) queries again into the private network, with the same results. These requests persists for more than two minutes ( over 200 unresolved queries ). Then for whatever reason the agent gives up and the already downloaded pdf file loads into the browser.
    I have a TCP capture file if you want it.

    Hi,
    I have the same problem with some specific PDF files. For more than 90% it hangs when opening the file, but sometimes it works (with the same file).
    The workflows where it sometimes worked:
    a) Loading the PDF, the reader is started the first time and displays license dialog.
    b) The reader was already runing and file is loaded with Drag&Drop or File/Open in the Reader
    But most times it does not load.
    I could not find out which file is missing or trying to be opened. So I tried with the CP949.TXT.
    I found no CP949.TXT in Reader 8 installation, so I took it from the link, pasted into notepad and stored in the respective directory
    C:\Program Files (x86)\Adobe\Reader 9.0\Resource\TypeSupport\Unicode\Mappings\win\
    Now it seems to work fine, opening PDFs with double click from exporer.
    But why did Adobe Reader 8 not have the TypeSupport directory at all?
    Even when having found a fix (hack?), I think I did not understand the cause of this problem.
    Regards,
    TheLastReader

  • Downloading a file via JSP

    I am trying to write some code which will generate a file and then download the file
    from my Webserver. When I download the file I get "Error 500: OutputStream already obtained"
    appended to the file. I can't work out why this is so.
    Here is the code I have used to download the file.
    I have also included the file before and after transmission.
    Any help would be appreciated.
    <%@page import="java.net.*,javax.servlet.http.*,javax.servlet.*,java.io.*" %>
    <%
    ServletOutputStream out1 = response.getOutputStream();
    String fileName = (String)request.getParameter("filename");
    // MIME type for pdf doc
    response.setContentType("application/x-download");
    response.setHeader("Content-Disposition","attachment;filename="+fileName+";");
    File f = new File("\\"+fileName);
    FileInputStream stream = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(stream);
    BufferedOutputStream bos = new BufferedOutputStream(out1);
    byte[] buff = new byte[2048];
    int bytesRead;
    // Simple read/write loop.
    try {
    while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
    bos.write(buff, 0, bytesRead);
    } catch (Exception e) {
    if (bos != null) bos.close();
    e.printStackTrace();     
    finally {
    if (bis != null) bis.close();
    if (bos != null) bos.close();     
    if (stream != null) stream.close();     
    %>
    This is the file on the WebServer
    The Quick Brown Fox Jumps Over The Lazy Dog
    The Quick Brown Fox Jumps Over The Lazy Dog
    The Quick Brown Fox Jumps Over The Lazy Dog
    This is the file after it has been transferred
    The Quick Brown Fox Jumps Over The Lazy Dog
    The Quick Brown Fox Jumps Over The Lazy Dog
    The Quick Brown Fox Jumps Over The Lazy DogError 500: OutputStream already obtained
    Thanks
    Adrian Campbell
    Honda Australia

    The JSP automatically gets an outputstream/writer, and starts writing to the output. In fact thats where the implicit variable "out" comes from.
    Couple of things to be aware of:
    Every carriage return outside of a <% %> tag in a JSP gets converted directly into the html as out.println("\r\n");
    That means the generated servlet has started writing even before you get the outputstream - which is what raises the exception.
    There are two ways to stop this
    1 - write it in a servlet - its purely code, with no HTML so servlet is better suited.
    2 - have no carriage returns outside of JSP tags <% %>. You currently have one - one the very first line. Try it like this:
    <%@page import="java.net.*,javax.servlet.http.*,javax.servlet.*,java.io.*" %><% 
    ServletOutputStream out1 = response.getOutputStream();
    %>  // and no carriage return at the end eitherThat should do it.
    As an aside, if you are going to be generating a text file, then you can use the implicit writer "out" as opposed to the OutputStream.
    Cheers,
    evnafets

  • Downloading the file through transaction F110.

    Hi all,
           My requirement is to generate a payment file in EFT format(comma separated format) and to download that file to a PC location using the transaction F110. The EFT file needs to generated automatically after the payment run. So I am copying the standard program RFFONZ_T which is the payment medium program and adding my code to generate the EFT file there. After the program execution, the file needs to displayed in  the F110 transaction. But it is not coming in F110.

    Hello,
    Can you please confirm that the program name is maintained in FBZP?
    Goto FBZP --> Pymt Methods in Country --> Give the Payment Method name --> In the Pymt Medium tab, Select the "Use Classic pymt medium programs" & give your program name there.
    In F110, you can view the EFT through:
    Environment --> Pymt Medium --> DME Administration
    BR,
    Suhas
    Edited by: Suhas Saha on Feb 17, 2009 12:48 PM

  • Downloading a file in JSP & Servlet

    Hi all
    I want to download a file from a server to the local machine using JSP.
    Kindly send me solution on this if any body has any info on this.
    Also is it possible to download a file from a server to the local machine using servlets.
    Do send me the soluton as soon as possible.
    Rgds,
    Satya

    http://www.jguru.com/faq/view.jsp?EID=10646

  • Downloading the file through http.

    Had anyone tried to download the zip file through http. If anyone had, please help to approach this.Thanks in advance.
    Also the way to unzip the downloaded file.

    Thank u for reply.I am trying to download the content of the xml file and download using NSUrl and parse it using NSXmlParser.I would like to know is there any way to handle the huge amount to be downloaded.

  • Method to download a file through browser

    Hello,
    What is the ABAP method to download a file on desktop when the control comes in from the browser window?
    I have tried with "cl_gui_frontend_services=>gui_download" method but this does not work and gives unknown error exception.
    Is there an alternate method to achieve the download functionality?
    Best Regards,
    Pankaj

    Hi Tamás,
    No, I am using a WAD template and there is a button on the WAD report. When I click on button, the selection binding parameters are passed to my customised class through a planning function. Within the implementation of class method, I try to call the GUI_DOWNLOAD method, where it does not work.
    Is there any alternative to this?
    Best Regards,
    Pankaj

  • Download Excel file using JSP

    Hi All,
    I am working on a JAVA/JSP application. JSP page passes the user inputs to JAVA page (using POST method) which queries to the database and generate an Excel file and returns the link for that file. I am displaying that link in JSP page ("Your file is successfully saved. Click here to download or view your file).
    Now what I want is when the user clicks on the link, open/save dialog will appear which give flexibility to the user to download or view the file in same JSP page. The problem is I don�t want to post again the data or dont want to open a child window. How to set the content type without posting it (I don�t know much about this). Is there any way to do this?
    Any help is highly appreciated. Thanx in advance
    Cheers
    Inderpal

    Hi
    Iam retreiving a file which is in image type in Ms SQl database, but while im retreiving the data from database using Servlet OutputStream the data is showing in binary format with all speciall symbols and text inside .Iamunable to find the solution for that,
    Pleas help me
    my code
              response.setContentType("application/msword");                    
                   OutputStream ros = response.getOutputStream();
              ros.flush();
                   ros.write(bt,0,bt.length);
    Thankz for ur help ,
    my id: [email protected]

  • Download a file through Struts

    Hey,
    I would like to provide an excel file download feature in my Struts application. How should i go about it. I know how to do it in regualr JSP/servlets but in struts i am little bit confused.
    here is what shoudl happen. In one of the Front end screens the user clicks on a button and the server should send a excel file( which is also generated dynamically at the server side) to the client. How do i go about it in struts.
    Thanks
    KM

    Pretty much exactly the same way you would in regular
    JSP/Servlets. What is different about it?
    Your Action can do anything that a servlet can do.
    Write to the output stream yourself, and then just
    return null, from the action to inform struts you have
    already taken care of the response.
    Cheers,
    evnafetsIt works... Thanks a lot for ur help evnafets

  • Download a file using jsp

    Hi All,
    I have a jsp with which I download the .Excel file from server, I am using i.e 6 my problem is when I click on download link it opens the file in same browser, How I can force it to open in excel not in a browser. It works fine fire fox.
    Please help.
    Thanks

    You need to set the correct response headers, these work fine for me:
    //control cache, these make the difference
    response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "Public");
    //these are xls specific
    response.setHeader("Content-Disposition", "attachment; filename=action.xls");
    response.setHeader("Content-Type", "application/vnd.ms-excel");Does this help you? Otherwise let us know which framework you're using so we can provide you with more details.

  • System tries to download .jnlp file through SSL

    Using Tomcat5 on Windows when running HTTPS, when I click the link to Launch my .jnlp file it just tries to download it to my file system. When I disable SSL and run nomally with HTTP, it works fine. Why won't JWS pick it up through HTTPS???
    THANKS!

    Check the mime-types... generally download errors happen if the mime-type is not properly delivered by the server. I fear it may be Tomcat does this.
    To check the mime-type, try to see inside the download-manager of the browser, or something such.
    paul

  • How to download Excel file in JSP Page

    Actually I have a page
    Where I am uploading the files to server and it is listing the files which are all uploaded to the server.
    If I try to click the file which is uploaded it has to download to the local system.
    DOC, TXT, PDF, PPT. These file formats are try to download to local. But Excel file, opening the file content only not downloading to local.
    Any solution

    Hi Bangalore:
    As my experience,there may be some symbol such as "\r\n" was added in the content of the Excel file you want to download. this is no porblems to text format file, but to binary format file, such file can not be open. So I suggest you check-up the content of the file befor it was writed to the client, remove unwanted symbol, it should be word!
    I'm a newer to the here , and my english is poor. I thirst for intercommunion, I'm sorry for the syntax error in my reply.

  • Download Excel file through Web dynpro with no windows open?

    Can we have a web dynpro application that just returns an Excel file in the response with no open windows? Similar to a java servlet that is used to download a Excel file?
    This basically means that I cannot use wdComponentAPI.getWindowManager().createNonModalExternalWindow()
    Java Servlet Code
    HttpSession session = request.getSession();      // get a handle on the session id
    response.setContentType("application/download");
    response.setHeader("Content-Disposition", "filename=RTIS_Report.xls");
    PrintWriter out = null;
    out = response.getWriter();
    String report = request.getParameter("REPORT");
    JCO.Table lines = download(request, session, report);
    for (int i = 0; i < lines.getNumRows(); i++) {
         lines.setRow(i);
         String content = lines.getString("LINES") + "\n";
         out.write(content);
         out.flush();
    out.flush();
    out.close();

    Hi,
    I think you can use IWD Cached Web Resource to achieve this..
    See the below code FYI..
    public void downloadToExcel( )
        String fileName = "Customer" + ".xls";
         IWDCachedWebResource cachedExcelResource = null;
         try
              File f = new File("Customer.xls");
              WritableWorkbook workbook =   Workbook.createWorkbook(f);
              WritableFont black = new WritableFont(WritableFont.createFont("Trebuchet MS"),WritableFont.DEFAULT_POINT_SIZE,WritableFont.BOLD,false,UnderlineStyle.SINGLE,Colour.BLACK);
              WritableCellFormat blackFormat = new WritableCellFormat(black);
              WritableFont blue = new WritableFont(WritableFont.createFont("Trebuchet MS"),WritableFont.DEFAULT_POINT_SIZE,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,Colour.BLUE);
              WritableCellFormat blueFormat = new WritableCellFormat(blue);
              WritableSheet sheet = workbook.createSheet("Customer", 0);
                   Label label;
                   String[] header={"Corporate Code","Batch ID"};
                   for (int i=0;i<2;i++)
                        label = new Label(i,0,header<i>.toString(),blackFormat);
                        sheet.addCell(label);
                   WritableCellFormat integerFormat = new WritableCellFormat(NumberFormats.INTEGER);
                   jxl.write.Number number;
                   // Reading the contents
                   for(int i=0;i<wdContext.nodeVn_DownloadToExcel().size();i++)
                        String strCorpName = wdContext.currentContextElement().getVa_CorpCode();
                        String strBatchID =     wdContext.nodeVn_DownloadToExcel().getVn_DownloadToExcelElementAt(i).getVa_BatchID();
                        label = new Label(0,i+1,strCorpName,blueFormat);
                        sheet.addCell(label);
                        label = new Label(1,i+1,strBatchID,blueFormat);
                        sheet.addCell(label);
                   workbook.setColourRGB(Colour.LIME, 0xff, 0, 0);
                   workbook.write();
                   FileInputStream excelCSVFile = new FileInputStream(f);
                   IWDCachedWebResource cachedWebResource = null;
                   if (excelCSVFile!= null)
                        cachedWebResource = WDWebResource.getWebResource(excelCSVFile, WDWebResourceType.getWebResourceType("xls","application/ms-excel"));
                   cachedWebResource.setResourceName(fileName);
              cachedExcelResource = cachedWebResource;
              wdContext.currentContextElement().setVa_DownloadToExcel(cachedExcelResource.getURL());
              workbook.close();
         catch (Exception ex)
              wdComponentAPI.getMessageManager().reportException("Error in Excel Download"+ex.getMessage(),false);
    Regards,
    Vijay

  • Simple Question Calling methods from Java files through JSP without JVM

    Hi.
    I've got a simple question (forigve my newbieness)...
    If I'm running Tomcat can I exectue a method in a compiled Java file from a JSP page without having the JVM installed on the server?
    Any thoughts or additional comments would be appreciated.
    Many thanks.

    No... but that's because you can't run Tomcat without
    a JVM installed on the server.
    If you are running Tomcat, you are running a JVM for
    the JSP pages to run in, in which case, yes, the JSP
    pages can call the other Java code... as long as it's
    in the classpath.Thanks a lot for the replies.
    So just to check, if I sign up with a hosting company that offers Tomcat then the JVM will be installed on the server and I can call other Java code as long as it's in the classpath?
    I just want to make sure before I sign up with a hosting company =D
    Thanks again!

Maybe you are looking for

  • Do I have enough "horsepower" to adequately run Leopard?

    Hello there, This are my specs: Dual 1GHz MDD, 2 GB RAM, ATI RAdeon 9800 Pro (128), Maxtor 500 GB (16 MB cache) for system and apps, Maxtor 500 GB (16 MB cache) for documents. Both drives are connected to the ATA100 on-board controller. Is this enoug

  • "clone database creation in progress" hangs

    I am attempting to install Oracle 9i personal on an XP machine. When the install gets to "clone database creation in progress, it hangs. I cannot successfully stop that part of the install. I have to click the close button at the top right of the win

  • Set text issue

    I have made a picture rotator for my website, but when I click on the image (which initiates the rotation to the next picture) the javascript SHOULD change the text of the specified layer, but instead of changing the HTML, it just posts the code on t

  • Increase maximum size of removable disk on Microph

    I couldn't find an answer on this one. Someone knows if it's possible? Thanks in advance.Message Edited by creativevin on 05-27-200707:3 PM Message Edited by creativevin on 05-27-200707:36 PM

  • Background report execution

    Dear Experts, I want to learn the process of executing any objects like reports, smart-forms in background.Pls suggest how to proceed. Thanks in advance. Regds Anand