Problem opening excel file in new window

Hi,
I have a JSF application that sends an Excel file back to the user.
My backing bean has a method that uses POI to generate the excel file and then write it to the servlet response.
This works fine if I call the method from a command button, but this displays the file in the current browser window, whereas I want to open the file in a new window.
I added an onclick javascript call to a command button which does a window.open() to open a jsp in a new window. The jsp contains an empty view, as I'm using an on-load phase listener to make the call to my backing bean method which should send the excel file when the file opens.
However, when the window opens, I get an IE error message saying 'Could not open xxx.faces', and then an excel error message saying 'Could not open xxx.xls. This may be because the file does not exist, or the file is already open etc etc'
However, I found that if the popup window goes through a servlet (which just forwards to the jsp page) instead of going to the jsp directly, it works like a charm.
Any ideas or suggestions on how to fix this would be very much appreciated. If I can't fix it I'll just stick with the servlet approach, although it just seems a bit messy.
(I'm using IE6 SP2, tomcat 5.5 btw)
Cheers,
Stuart

I'm doing a similar thing, but I use commandLink to lauch the window. CommandLink has the "target" attribute that I set to _blank.  As you would expect, that opens up the page in the new window.                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Not able to open excel file in new window any one plese help me as early

    Hi all,
    I have a imag tag in jsp on click on the image i am submitting the form
    1. i have used the below code
    HSSFWorkbook wb=viewHelper.getExcel();
    response.reset();
    ServletOutputStream outs = response.getOutputStream();
         response.setContentType("application/vnd.ms-excel");
         response.addHeader("Pragma", "No-cache");
         response.addHeader("Cache-control", "no-cache");
         response.addDateHeader("Expires",1 );
         wb.write(outs);
         outs.flush();
         outs.close();
         return;
    2. I got one dialog box to open ,save,cancel . if i try to open it is openeing in the same window i had made the request. i need it to ask for in which type of application to open. i.e, in excel , notepad,.....
    please mail me as soon as possible
    [email protected]

    I had a similar porblem....
    I got some help from...http://www.javaworld.com/javaworld/jw-10-2006/jw-1019-xmlexcel.html?page=1...
    This is my code in servlet...
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet spreadSheet = wb.createSheet("Users");
    spreadSheet.setColumnWidth((short) 0, (short) (256 * 25));
    spreadSheet.setColumnWidth((short) 1, (short) (256 * 25));
    // Creating Rows
    HSSFRow row = spreadSheet.createRow(0);
    HSSFCell cell = row.createCell((short) 1);
    cell.setCellValue("Year 2005");
    cell = row.createCell((short) 2);
    cell.setCellValue("Year 2004");
    HSSFRow row1 = spreadSheet.createRow(1);
    HSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
    cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
    cell = row1.createCell((short) 0);
    cell.setCellValue("Revenue ($)");
    cell = row1.createCell((short) 1);
    cell.setCellValue("25656");
    cell = row1.createCell((short) 2);
    cell.setCellValue("15457");
    FileOutputStream output = new FileOutputStream(new File("/tmp/Users.xls"));
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "attachment;filename=Users.xls");
    ServletOutputStream out = response.getOutputStream();
    wb.write(output);
    output.flush();
    output.close();
    forward = null;
    In firefox i get the download dialog box but not able to open in from there,i need to save it and then open. In IE i dont get the dialog box instead the excell open inside the browser......Please help me to open a excel sheet onclick on a link "Export to excel" in jsp......
    Thanks in advance...

  • Problem in opening excel file in different window

    hi
    i want to open excel file in different window it open in same window properly on the bases of condition but when i try to open in different with window.open( )
    it give error that file has already used or path not exist OR requisted site either unavailable
    how can i rectified

    Hi.
    I am too facing the same problem. I am using Jakarta Poi to display my resultset in an excel sheet directly(and not into a jsp)
    The browser opens a window showing Open Save Cancel. If i click and save the excel sheet and then open, it opens. But clicking on Open directly doesnt open the excel sheet. Rather it gives the same error
    The file name or path name does not exist.
    The file you are trying to open is being used by another progrtam . close the document in other program and try again
    The name of the work book your tring to save is the same as name of another document that is readonly .try saving workbook with different name
    Can somebody please help me fix this problem, since its an urgent requirement. Mail me at [email protected]
    Thanks
    Hitesh

  • Problems opening .pdf files created in Windows in MAC

    My clients that are using Macs are having problems opening password protected PDFs that I created in Windows. Any suggestions?

    Are your clients using Adobe Reader on Mac, or the built-in Mac OS Preview?  Preview does NOT support the full PDF standard :(.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Mon, 26 Sep 2011 15:04:18 -0700
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Problems opening .pdf files created in Windows in MAC
    Problems opening .pdf files created in Windows in MAC
    created by Hollcy<http://forums.adobe.com/people/Hollcy> in PDF Language and Specifications - View the full discussion<http://forums.adobe.com/message/3939175#3939175

  • Problem opening excel files exported from Discoverer Plus 10.1.2.48.18

    I can't open excel files (xls) exported from Discoverer Plus 10.1.2.48.18 when I enable macros. The application (Excel) hangs up.
    Someone have any idea about this?
    Thanks,
    Diego

    Hi Meifang
    I did some more research and found a document on MetaLink 250820.1 that talks about Discoverer not being able to call Excel if Discoverer is running via an IP address instead of a qualified domain name.
    The article talks about making Discoverer a trusted site in the Internet Options of IE. Here's the relevant info from the posting:
    Workaround for MS IE (if necessary):
    1. Open a new MS IE browser
    2. Navigate to: Tools | Internet Options Security where you will see the Trusted Sites icon (green icon with a check mark)
    3. Click the Sites button
    4. Add the following: http://IP:port/
    (where IP, port are the location of where Discoverer server is running)
    5. Click the OK button
    6. Click the OK button again
    On my own PC, I was having a similar problem and I was unable to get Excel to launch. In the end I did this:
    1. Open a new MS IE browser
    2. Navigate to: Tools | Internet Options | Security where you will see the Local Intranet icon (computer icon against a globe)
    3. Click the Local Intranet button
    4. Click the Sites button
    5. Click the Advanced button
    6. Add the following: http://IP/ or http://website
    (where IP or website are the location of where Discoverer server is running)
    7. Click the Add button
    8. Click the OK button
    9. Click the OK button again
    10. Click the OK button a third time
    With this done, I made sure that my Explorer settings were correct by doing the following to ensure that a couple of settings for the .xls & .html file types are unchecked:
    1. Open Windows Explorer
    2. Navigate to: Tools | Folder Options | File Types tab
    3. Highlight the Extension XLS (or HTML)
    4. Click the Advanced button
    5. At the botton of the screen are three settings that use checkboxes. If either of the following two are checked, un-check them:
    Confirm Open after Download and Browse in same window
    6. Click the OK button
    7. Click the Apply button
    8. Re-boot the PC
    After I did this I was successfully able to get Excel to open from within Discoverer.
    Best wishes
    Michael

  • How to make fileDownloadActionListener to open pdf file in new window

    Hi all ,
    i used the component [ fileDownloadActionListener ] to make download pdf file ,
    my question is
    How make this components to download and open file in new window ?
    Jdeveloper version 11.1.2.3

    Here is a sample http://technology.amis.nl/2011/07/28/adf-11g-show-pdf-in-a-popup/
    or http://mahmoudoracle.blogspot.de/2012/06/genius-adf-buttons.html#.UZygjrVM_Lk
    in General you can use the technique described here http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/ and configure hte browser to püen the doenloaded file using the configured application (pdf reader in your case).
    Timo

  • Link to open pdf file in new window

    I want to create a link on a web page to open a pdf file in a
    new window. I used the "on click" "open brower window". Which does
    open the pdf file, but not in a new window. How do I open it in a
    new window?

    Your code is a mess:
    ** there is no apparent reason for the span:
    <td><span class="style1"
    onfocus="MM_openBrWindow('pdf/PR_launch.pdf','','')">Milford, OH
    So change that line to:
    <td>Milford, OH
    ** here you have two double quotes before This.
    <a title="”This" class="pdfFile"
    onclick="MM_openBrWindow('pdf/PR_Launch.pdf','','')"
    Change it to this, (with some other improvements):
    <a title="This" class="pdfFile"
    onclick="MM_openBrWindow(this.href,'','');return false"
    ** This is code salad:
    href="”PR_Launch.pdf”" link="" will="" open="" a=""
    .pdf=""
    file.”="">More (PR_Launch.pdf,
    230kb)</a></span></td>
    Change it to:
    href="pdf/PR_Launch.pdf">More (PR_Launch.pdf,
    230kb)</a></td>
    If you continue to have trouble, you might find my divaPOP
    Extension
    easier, and far more powerful. It automat6ically opens pdf
    files and
    links to all external files in a popup window without your
    needing to
    code each link:
    http://www.divahtml.com/products/divaPOP/open_popup_windows.php
    E. Michael Brandt
    www.divaHTML.com
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • Is it possible to open Excel file in XAML Windows Store App?

    Hi,
    I want open excel file from local folder(not from Url) within the windows store app.
    Could you please help me how to implement ?
    Thanks,
    Siva varri
    Thread response from msdn

    Hi,
    If you want to open an excel file by a windows store app. There is no direct API in windows store app can handle excel file. You will need to find a third party component. But
    if you want to launch a file into its default handler, please see 
    Launcher.LaunchFileAsync API. And you can refer to the link below:
    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh779671.aspx
    private async void Button_Click(object sender, RoutedEventArgs e)
    StorageFolder storageFolder =
    Windows.Storage.ApplicationData.Current.LocalFolder;
    StorageFile file =
    await storageFolder.GetFileAsync("56.xlsx");
    if (file != null)
    // Launch the retrieved file
    var success = await Windows.System.Launcher.LaunchFileAsync(file);
    if (success)
    // File launched
    else
    // File launch failed
    else
    // Could not find file
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How to stop prompt while opening an excel file in new window

    hi all
    i made one table in jsf and i am having two icons corresponding to each row one for open and one for save. on the click of open i am calling web services getting the excel file and opening it but it is happening only . when i choose to open option from the prompt which comes when i click on the link. how to remove that prompt so that on click of the open it should directly open the excel file. plzzzzzzzzz hepl

    in the url of the new page that you are opening add --> &RetainAM=Y at the end.
    Following points should be useful :
    Suppose ,you have to open a new window from your page by clicking on a link or a button and after opening, when you click on any button in the parent page, if you are getting a session out error… try the following solutions:
    1.     Add retainAM=Y in the destination URI of the button or link
    2.     If you have the back button handling in your code, ensure that…
    if (!pageContext.isBackNavigationFired(true)) is written instead of
    if (!pageContext.isBackNavigationFired(false))
    3.     Also ensure that the trasaction name is exactly same in both startTransactionUnit and end TransactionUnit
    TransactionUnitHelper.startTransactionUnit(pageContext, "sameName");
    TransactionUnitHelper.endTransactionUnit(pageContext, " sameName ");

  • Problem displaying PDF file in new window.

    Using NetBeans 6.5, Internet Explorer 7.
    I am using the code example from BalusC at the site:
    http://balusc.blogspot.com/2006/05/pdf-handling.html
    I am having no problem reading and displaying the PDF file, but it displays it in the same window,
    not a new window and it overwrites the current page, so I can't use the back arrow to fetch the page that is overwritten.
    I am using a commandLink to fetch the file.
    Does anyone know why I am not getting a new window or tab for the display?
    The jsp portion for the link is:
    <h:commandLink action="#{MainPage.linkAction3_action}" id="linkAction3"
              style="color: rgb(0, 0, 0); font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bold; left: 280px; top: 0px; position: absolute"
              target="_blank" value="Insurance Document"/>The "MainPage.linkAction_action" method just makes a call to the display function:
        public String linkAction3_action() {
            sb1.setMessage("");
            dsb.setFilePath("C:/");
            dsb.setFileName("Insurance_Summary.pdf");
            dsb.downloadPDF();
            return null;
        }And the downloadPDF() method is basically a cut and paste from the BalusC site;
        public void downloadPDF()
            // Reference:   http://balusc.blogspot.com/2006/05/pdf-handling.html
            // Prepare.
            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
            File file = new File(getFilePath(), getFileName());
            BufferedInputStream input = null;
            BufferedOutputStream output = null;
            try {
                // Open file.
                input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
                // Init servlet response.
                response.reset();
                response.setContentType("application/pdf");
                response.setContentLength( (int)file.length());
                response.setHeader("Content-disposition", "inline; filename=\"" + fileName + "\"");
                output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
                // Write file contents to response.
                byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
                int length;
                while ((length = input.read(buffer)) > 0) {
                    output.write(buffer, 0, length);
                // Finalize task.
                output.flush();
            catch( Exception e )
                System.out.println( "Error displaying file.");
            finally {
                // Gently close streams.
                close(output);
                close(input);
            // Inform JSF that it doesn't need to handle response.
            // This is very important, otherwise you will get the following exception in the logs:
            // java.lang.IllegalStateException: Cannot forward after response has been committed.
            facesContext.responseComplete();
        }

    1) window.open will open a new window and call a servlet.
    window.open ("http://path_to_yourservlet/PDFServlet", "newWindowName");
    if you ant to pass some values from your web page to the servlet you can pass as
    window.open ("http://path_to_yourservlet/PDFServlet?param1=value1&param2=value2", "newWindowName");
    2) The servlet will fetch and display the pdf file.
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class PDFServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet
         private final static int DEFAULT_BUFFER_SIZE = 1000;
         public PDFServlet()
              super();
         public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              String fileName = "Insurance_Summary.pdf";
              File file = new File("C:/"+fileName+"");
              response.setContentType("application/pdf");
         OutputStream output = response.getOutputStream();
         BufferedInputStream input = null;
         //BufferedOutputStream output = null;
         try {
         // Open file.
         input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
         response.setContentLength( (int)file.length());
         response.setHeader("Content-disposition", "inline; filename=\"" + fileName + "\"");
         output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
         // Write file contents to response.
         byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
         int length;
         while ((length = input.read(buffer)) > 0) {
         output.write(buffer, 0, length);
         output.flush();
         catch( Exception e )
         System.out.println( "Error displaying file.");
         finally {
         input.close();
    Regards,
    Milind Dhar

  • Open download file in new window.

    Hi,
    I m using oracle 11g and Apex4.0.2 version
    Browser IE8.
    I m downloading PDF file when a button is pressed.
    The code will be
    htp.init;
    OWA_UTIL.MIME_HEADER(NVL(L_V_MIME,'application/octet'),FALSE);
    owa_util.http_header_close;
    WPG_DOCLOAD.DOWNLOAD_FILE(BLOB_content);
    It works fine by opening the pdf file.
    But I need the pdf file to be opened in new tab page or in new window.
    Is it possible?

    vk,
    it seems your page process is not triggering or it was not working quite right in the first place.
    It should be something lke this:
    Name: DOWNLOAD_FILE
    Type: PL/SQL anonymous block
    Process Point: On Submit - After validations
    When Button Pressed: DOWNLOAD
    Source
    /* if the BLOB content is stored in wwv_flow_files: */
    DECLARE
      l_blob_content wwv_flow_files.blob_content%TYPE;
      l_mime_type    wwv_flow_files.mime_type%TYPE;
    BEGIN
    SELECT blob_content, mime_type
    INTO  l_blob_content, l_mime_type
    FROM  wwv_flow_files
    WHERE  ... /* how you access your file */
    htp.init;
    OWA_UTIL.MIME_HEADER(NVL(l_mime_type,'application/octet'),FALSE);
    owa_util.http_header_close;
    WPG_DOCLOAD.DOWNLOAD_FILE(l_blob_content);
    --apex_application.stop_apex_engine;  /* APEX 4.1 and above */
    apex_application.g_unrecoverable_error:= true;  /*before APEX 4.1 */
    END;Jens

  • Open html file in new window it is opening in calling browser.

    Hi ,
    Am using adf 11.1.1.5 jdev.
    I have a pop in which pdf,html and rtf file extension are mentioned in drop down list . As i select htlm and fire command button .
    The generated html file is opening in the same browser which is replacing the calling page . I want to open in new window .
    thanks .

    Hi,
    iff you use ADF Faces, use a goLink with a target to _blank. If you don't use ADF Faces, provide more details to the question
    Frank

  • How to open PDF file in new window as default

    I have .pdf documents into which I have inserted links to other .pdf documents using pdfEdit995
    (I am a 77-year-old pensioner recording monumental inscriptions, not very computer literate and not able to afford expensive applications !) 
    The links in the temp.ps file (which pdf995 creates first) look like :-
    [ /Rect [85 225 107 228]
    /Border [ 0 0 0 ]
    /Action /Launch /File (.\\Another Folder\\TARGET FILE.PDF)
    /Subtype /Link
    /ANN pdfmark
    The links work fine, but open in the same window, which is annoying as it is then neccessry to re-open the original document, scroll down to the required page and find the next link.
    pdf995 support say that perhaps Adobe reader can be set to open in a new window, but I want this to be the default when I circulate my file to interested people, so would prefer to modify the links.
    Can anyone help with a smple solution ? (I also believe in Santa Claus !)
    System: Vista; Reader X 10.1.0

    I don't know if you can change this in the PS file, but if you had Acrobat you could embed the following code into your file, that will make sure the links open in a new window. However, you should be aware that this code will change the preferences at the application level, which some people might not appreciate.
    The code is:
    app.openInPlace = false;

  • How come I can't open Excel files from a Windows computer on my Mac?

    My roommate created several Excel spreadsheets on his Windows XP computer and saved them. I put a USB drive in his computer and copied those files to the USB drive and then placed the USB drive in my MacBook. When I go to open the file, it indicates that the files are being used by another user and that it can't open them. What's going on?

    What happens if you copy them to the computer and eject the USB drive?

  • Please help to open PDF file in new window

    Hi!
    I have a My.pdf file, and file Other.pdf located in subfolder Myfolder.
    For example, my.pdf located on c:\Mydocs\My.pdf and Other.pdf located in c:\mydoc\Myfolder\Other.pdf
    I try make plugin that open Other.pdf in subfolder Myfolder, no matter in where My.pdf is located on computer.
    I found in SDK API, that I need create a new window for open pdf file, using WinAPI function - CreateWindow:
    HWND externHWnd = CreateWindow ("ExternalWindow", "PDFViewer",WS_OVERLAPPEDWINDOW,50, 50, 500, 500, 0, 0, gHINSTANCE, NULL);
    I copy example into Visual Studio, but in example there no gHINSTANCE is undeclared.
    or plese provide working code for my task
    Please help

    In which part of the SDK did you look.
    Do you really mean a plugin (control Acobat from inside - can only be written using C#)
    oder do you mean control/work with Acrobat from an external application (like vb,..) via activeX (=IAC).
    br, Reinhard

Maybe you are looking for