Hi

my file is located at c:\AdminFiles.xml

i tried the following ways

window.open("c:/AdminFiles.xml",'HeavyXml');

window.open("c:\AdminFiles.xml",'HeavyXml');

window.open("c:\\AdminFiles.xml",'HeavyXml');

in the above i'm getting the following error:
"Firefox doesn't know how to open this address, because the protocol (c) isnt associated with any program"


window.open("file:///c:\\AdminFiles.xml",'HeavyXml');

the last attempt give to respond at all...

any suggestions???


thanks ahead.

Daniel

Dani AI

Generated

Short diagnosis and why your saved .html worked: the browser treats a page served by JSP (http/https) differently from a local file (file:). When the HTML is opened directly from disk the browser is already in the file: context, so a local file URI will resolve. When the page comes from a web server, modern browsers will not let script open arbitrary client filesystem paths for security — that’s why ’s copy/paste-to-.html test succeeded and why ’s file‑URI advice only helps in the local-file case. As pointed out, extensions can work but they require client installation and are not a general server-side fix.

Recommended, robust fix: serve the XML from your webapp (or stream it from the server) instead of trying to point the browser at a client drive path. Example (server-side): stream the server-side file and set a proper Content-Type and Content-Disposition so the browser will display or download it.

/* servlet or JSP streaming (short example) */
File f = new File("/path/on/server/AdminFiles.xml");
response.setContentType("application/xml");
response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
try (FileInputStream in = new FileInputStream(f);
     OutputStream out = response.getOutputStream()) {
    byte[] buf = new byte[8192];
    int r;
    while ((r = in.read(buf)) > 0) out.write(buf, 0, r);
}

If your goal is to let a user open an XML that lives on their machine, don’t try to dereference a C:\ path from a remote page. Use a file input and the FileReader API so the user explicitly picks the file and JavaScript can read it client‑side. That avoids security restrictions and works across browsers.

Troubleshooting checklist: confirm whether the path you used refers to the client or the server; open the browser console for “blocked local resource” messages; put the XML under your webapp and request it by relative URL during testing. Serving the file from the server or using a user-picked file are the safest, cross-browser solutions.

Recommended Answers

All 5 Replies

file:///C:/AdminFiles.xml

i found out that the problem is something else...
all this mambo jumbo about opening the xml is inside a jsp file....
I did the following test, i did "view source" and copy/paste into an .html file and opened inside Firefox , and it works just fine!!!!!
What could be the problem??? :/

gonna post a thread in JSP forum....

thx 4 the help

Hi ,
IAm trying to open a file from JSP And getting a same problem as you had.

It says Firefox does not know how to ope this program.

I have my file on c:\pay\out\paystatement.pdf I have to open it from a JSP.

Can you help me how did you resolve the problem??

Thank you for help

Chetan

I really don't remember... Sorry

Hi

my file is located at c:\AdminFiles.xml

i tried the following ways

window.open("c:/AdminFiles.xml",'HeavyXml');

window.open("c:\AdminFiles.xml",'HeavyXml');

.....

Daniel

Install LocalLink extension for firefox.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.