How to open a local file from javascript in a jsp-page

Hi
I have created an iview from a PAR file. In the par file I have a jsp-page with some javascript code. From the javascript coe I want to open a new window with an Excel file.
I have tried window.open("c:
test.xls", "test_window"), but it doesn't seem to work. I have created a small HTML page locally with the same command and there a new window opens with the Excel file.
If I change the local file path with an URL it also works.
Any idea how to open a local file ?
Thanks
/Jakob

Jacob,
I'm not 100% (but 99,9%) and it has to do with security ristrictions of the browser not allowing to have local workstation interation from the web. This is ofcourse very dangerous if the browser would allow it... So therfore it is blocked. What if somone would point to a file/executable that formats your drive so for that reason it is not allowed to have web interaction with a local file. Only with Java Applets this is possible but still with many limitations, and what I remember Google Gears and Adobe Air do have some limited web 2 local file interaction... So best and most simple solution you are left with is pointing to a url instead of a file on a c:\ drive.
PS The reason why it works when you start the html from your local PC has todo with the fact that the browser detects that the html is not running in the web at that moment therefor allowing the access.
Cheers,
Benjamin Houttuin

Similar Messages

  • How can I access xml document from javascript whithin a JSP page

    how can I access xml document from javascript whithin a JSP page?
    I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
    Thanks in advance!

    The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
    It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation.

  • Open a local file from a web Service

    Hello!
    Likely this is a trivial question, but I need to open a local file from a Web Service and i don't know how to get the file path. I mean that I have a WS source code placed in a proper package (my.ws.package) with an additional configuration XML file placed in the same directory. I need to read it, but if I use merely
    File conf = new File("Conf.xml");it can't find it. I've tryed with:
    MyWS.class.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()in order to get the file path, but a
    java.security.AccessControlException access denied (java.lang.RuntimePermission getProtectionDomain)arises...
    I don't know...
    Suggestions?
    Thanks.
    Anhur

    Hello!
    Likely this is a trivial question, but I need to open a local file from a Web Service and i don't know how to get the file path. I mean that I have a WS source code placed in a proper package (my.ws.package) with an additional configuration XML file placed in the same directory. I need to read it, but if I use merely
    File conf = new File("Conf.xml");it can't find it. I've tryed with:
    MyWS.class.getClass().getProtectionDomain().getCodeSource().getLocation().getPath()in order to get the file path, but a
    java.security.AccessControlException access denied (java.lang.RuntimePermission getProtectionDomain)arises...
    I don't know...
    Suggestions?
    Thanks.
    Anhur

  • How to open Adobe Reader file from another native IOS application?

    There is an existing thread, but I want to re-open it because I think this is an important feature that we need badly.  I was wondering if there is any plan to add this feature so we can open PDFs directly into Adobe from the web / other apps.
    How to open Adobe Reader file from another native IOS application?
    Basically, we just want to use a custom URL scheme to open a specific document in the App.  Currently, this only opens the app but does not load the file.
    APB

    Not to hijack the conversation but I can explain why this would be useful for both the above case and another.
    What I believe Pavel is talking about is setting up a "URL Scheme" for the Adobe Acrobat iOS application so that you can easily open a PDF specifically in Adobe Acrobat iOS from other native applications and even from web applications opened within Safari. This is particularly useful if your application requires some of the specific features in Adobe Reader iOS to grant them the best experience possible and you want to encourage this.
    Another case: If you're using Adobe Livecycle's document security modules (that encrypts PDF files so that Adobe Acrobat must "phone home" to decrypt and view the document), these PDF's can only be viewed inside the Adobe Acrobat application and appear as blank in most other PDF readers. Having a URL scheme allows your application utilising this functionality to have a 1 click step to view the PDF rather than the current non-user friendly process:
    - Within Safari, touch the PDF link (appears as blank in the default Safari PDF reader, which in itself is confusing)
      - Touch "Open in..."
      - Touch "Adobe Acrobat"
    We have an immediate need for this functionality for the example above. I can resubmit it in a separate post if necessary.

  • How can we  use java variable in javascript code on JSP page?

    How can we use java variable in javascript code on JSP page?
    Pls help

    Think about it:
    JSP/Java is executed on the Server and produces HTML+JavaScript.
    Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
    Obviously there's no way to access a Java variable directly from JavaScript.
    What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable.

  • Open a Local file from JSP

    Hi All,
    I want to access a local file from a JSP. On click of the link the local file should open. The location of the local file is
    O:/VWS00000000000000000001/REPORT_FRAGMENTS/Title1.doc
    and the hyper link on the JSP shows
    file:///O:/VWS00000000000000000001/REPORT_FRAGMENTS/Title1.doc
    somehow the file does not open from the JSP page but it opens from the browser if I type
    'file:///O:/VWS00000000000000000001/REPORT_FRAGMENTS/Title1.doc' in the address bar.
    Can anybody please help.
    regards,
    Shardul.

    if you'd like to show the real path to the user, use simply an ftp server !
    however, if you prefer a secure solution, so use a servlet:
    example:
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SendWord extends HttpServlet {
      public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        //get the 'file' parameter
        String fileName = (String) request.getParameter("file");
        if (fileName == null || fileName.equals(""))
          throw new ServletException(
              "Invalid or non-existent file parameter in SendWord servlet.");
        // add the .doc suffix if it doesn't already exist
        if (fileName.indexOf(".doc") == -1)
          fileName = fileName + ".doc";
        String wordDir = getServletContext().getInitParameter("word-dir");
        if (wordDir == null || wordDir.equals(""))
          throw new ServletException(
              "Invalid or non-existent wordDir context-param.");
        ServletOutputStream stream = null;
        BufferedInputStream buf = null;
        try {
          stream = response.getOutputStream();
          File doc = new File(wordDir + "/" + fileName);
          response.setContentType("application/msword");
          response.addHeader("Content-Disposition", "attachment; filename="
              + fileName);
          response.setContentLength((int) doc.length());
          FileInputStream input = new FileInputStream(doc);
          buf = new BufferedInputStream(input);
          int readBytes = 0;
          while ((readBytes = buf.read()) != -1)
            stream.write(readBytes);
        } catch (IOException ioe) {
          throw new ServletException(ioe.getMessage());
        } finally {
          if (stream != null)
            stream.close();
          if (buf != null)
            buf.close();
      public void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        doGet(request, response);
    }hope that helps

  • How to open an InDesign file from CMIS repository?

    We are using CS SDK 2.0 , looking to use CMIS to keep versionning of .indd file. The uss case as following:
    form our de4veloped InDesign pluging, user click a button
    the button will open a .indd file from cmis repository
    plugin check-out the file, open it within InDesign IDE
    user make changes
    user make save
    the plugin export a pdf and swf files from the current document, if the files exists it will update, aslo on CMIS repo to keep also versions of exported pdf and swf, if files not exist in first time .. it will create
    when user clos the document , it will check it in.
    the problem there is no sufficent sample code for, even was thinking to use Adobe Drive, but there is no Adobe Drive SDK for Flex.
    i used to fuse the sdk, but
    private function getFileByPath(sPath:String):Fileable {
    appStatus = ">> get File By Path";
    message = "";
    viewEnabled = false;
    var request:GetObjectByPathRequest = new GetObjectByPathRequest(session);
    var oFileable:Fileable;
    request.path = sPath;
    request.execute(onSuccess, onError);
    function onSuccess (event:GetObjectByPathResponse) : void {
    oFileable = event.object;
    //var oDoc2:Document = new Document(event.object);
    doc = event.object as Document ;
    //children = new ArrayCollection(vectorToArray(event.target));
    appStatus = ">> getFileByPath : Success";
    viewEnabled = true;
    return oFileable;
    private function checkOutFile(oFile:Document):Document{
    appStatus = ">> Check Out File";
    message = "";
    viewEnabled = false;
    var request:CheckoutRequest = new CheckoutRequest(session);
    request.object = doc;
    var oDocument:Document;
    request.execute(onSuccess, onError);
    function onSuccess (event:CheckoutResponse) : void {
    oDocument = event.object ;
    appStatus = ">> Check Out File : Success";
    viewEnabled = true;
    return oDocument;
    private function openTestFile():void {
                                            appStatus = "Open Test File";
                                            message = "";
                                            viewEnabled = false;
                                            var oFile:Fileable  = getFileByPath("/Collaboration/test.indd");
                                            //var oDoc2:Document = new Document(oFile);
                                            var oDoc:Document  = checkOutFile(doc);
    i do not know what method in the CS SDK to open document fom active window and  how to map CMIS Document to com.adobe.indesign Document ?

    Dear Seoras
    i fixed the to return the cmis path:
    public function resolveRemotePath(file:File):String
                                  if (file.nativePath.indexOf(LOCAL_FILE_CACHE.nativePath) != 0)
                                            return null;
                                  var remoptePath:String =file.nativePath.substr(LOCAL_FILE_CACHE.nativePath.length);
                                  trace("resolveRemotePath [11] : "+ remoptePath);
                                  if(File.separator!="/") {
                                            //var pattern:RegExp = /(\/)/g;
                                            var pattern:RegExp = /(\\)/g;
                                            remoptePath =  remoptePath.replace(pattern ,"/");
                                            trace("resolveRemotePath [22] : "+ remoptePath);
                                  return remoptePath;
    i have another issue, why everytime update the generated pdf it creates new pdf file with same name in the cmis repo .. does the pdf is not updatable over the cmis service ???
    Regards

  • How to read a local file from Applet Code

    Hi
    I am developing a application and i want to access a local file from the applet
    So pls help me in coding for this

    You can't do that, at least not with an unsigned applet.
    Sign your applet and it should work just like normal file access.

  • How to print a local file from jsp

    Hi,
    I want to print a local file(eg. .doc,.pdf) from a jsp.
    Please help me with any answer or any example code
    Thanks in advance
    Regards,
    Sanjeev

    Try this:
    index1.jsp:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <Link rel='alternate' media='print' href=null>
    <script Language=JavaScript>
    function setPrintPage(prnThis){
    prnDoc = document.getElementsByTagName('Link');
    prnDoc[0].setAttribute('href', prnThis);
    window.print();
    </script>
    </head>
    <body >
    <a href="#" onclick="setPrintPage('index.jsp');"> Click to Print </a>
    </html>This will print index.jsp without opening it in browser. Hope this helps!

  • How to open a BUP file from a flashdrive in Macbookair?

    Pl let me know how to view a video with BUP extension from a flashdrive in my macbookair?

    You can open a PUB file ONLY with MS Publisher (Windows). No other possibility.

  • How to retrieve a local file from a portal report.

    Hi,
    I need to access a local htm file from my local directory. I stored the filename in
    a table. And I built a portal report to select the filename from the table. The filename
    in the report will be link to a procedure that I created to pass the filename. The
    procedure code is as follow:
    (v_filename in varchar2) IS
    url varchar2(100);
    BEGIN
    url := 'uploaddoc/'&#0124; &#0124;v_filename;
    portal30.wwv_redirect.url(p_url =>url);
    END;
    Then in the httpd.conf file, I put in an alias like this:
    I put an alias in the httpd.conf file like this:
    Alias /uploaddoc/ "C:\My_Data\uploaddoc/"
    I stopped the http server and restarted it after I made the changes.
    When I run the report, I click on the filename link: in my example,it is:
    internal_portal_faq, the filename is passed to the procedure that I created.
    But I got the following error message on the browser:
    No DAD configuration Found
    DAD name:
    PROCEDURE : internal_portal_faq
    URL : http://localhost:80/pls/portal30/uploaddoc/internal_portal_faq
    I am running on version 3.07 on NT on my laptop.
    Any idea what I did wrong?
    P.S. I don't want to upload the file using a portal form into the blob field.
    Thanks;
    Kelly.
    null

    Hi,
    I found out a way to do this myself. If anyone is interested in that, just drop me an email.
    Kelly.
    null

  • How to open an PDF file from Java Application

    Hi
    I am developing a GUI application in java swing.
    on clicking one button, I want to open PDF file from my swing application.
    Is there any API through which I can achieve this?
    Tapan Maru
    Sun Certified Java Programmer

    Here's a way to do it (if I understand you
    correctly). Just let explorer.exe do it for you.
    import java.awt.*;
    public class openPDF
         Desktop desktop = Desktop.getDesktop();
         public openPDF()
              open("test.pdf");
         public void open(String path)
              try
                   Runtime.getRuntime().exec("explorer.exe "+path);
    } catch(Exception e) { System.out.println("NAI!
    I! ERROR!\n"+e); }
         public static void main(String[] args)
              openPDF myApplication = new openPDF();
    Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)???
    -Puce

  • How to open/convert RAW- files from new CANON 5D Mk III in LR 3 and CS 5?

    Hallo!
    The RAW- files from my new CANON 5D Mk III are not convertible into LR 3 and CS 5.
    What is the reason and how to solve the problem?

    The work around of converting the CR2 to dng either with the dng converter or ACR 6.7 will allow working in LR and CS5 but not with the latest raw conversion engine from Adobe i.e PV 2012.
    Remember to keep a copy of the CR2 files if you wish to utilize the Canon software.

  • How to open an existing file from java

    Hi Guys,
    I have one problem Please help me in this.
    How to open file(i.e. file can be any type, it is may be image file, doc file or pdf file) using java.
    Even i tryed in one way but it is static way that is working in windows not for other OS.
    Code :
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
         DataInputStream din=new DataInputStream(System.in);
         System.out.println("Enter File Path to Open");
         String fName=din.readLine();
         File file=new File(fName);
    Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file.getAbsolutePath());
    catch (Exception err) {
    err.printStackTrace();
    If any other way to do please tell me.
    Regards
    Siva Prasad

    Well, if the OS doesn't provide a mechanism to associate a file name with a certain program, there's nothing you can do.
    I don't know whether something like JDIC can help you - otherwise, you'd have to find the solution for each OS. What's inside the exec()'s parenthesisses is not a Java problem anymore.

  • How to open Microsoft office files from my wp8 app?

    Is there any way to open Microsoft office documents? I want to open a doc file which is in my phone.My app may try to open pdf also. So is there any way for that? I need a free one.

    //where file is your StorageFile type object of perticular //Office documents i.e. ppt or doc etc
    await Windows.System.Launcher.LaunchFileAsync(file);
    Please Refer these links 
    How to open pdf file in Windows Phone 8?
    Launcher.LaunchFileAsync
    shah
    // Please Mark as answer if it is Helpful to you. Thank You

Maybe you are looking for