Can someone please help explain to me the differences between the two? The URL instance seems simple enough to me, but I am having trouble doing the same thing with a local file.
When accessing a file directly, chrome is repsonsible for accessing the file on disk and rendering it. When using a server, the server reads the file from disk and sends it over http, and then chrome renders it.
You may need to make sure you allow Chrome access to the local files. Add the --allow-file-access-from-files switch to your shortcut that starts chrome.
Otherwise, you will get errors when your HTML file tries to access other resources on disk.
See http://www.chrome-allow-file-access-from-file.com/
Update
For Firefox, you want to go to:
about:config
And change the flag for security.fileuri.strict_origin_policy to FALSE.
You should run HTTP server on your machine and make calls to http://localhost/
Related
This post is about a problem from the Java cache. We have a jnlp file responsible of updating our app (so we cannot put it “offline”). The problem is that some of our users run the application behind a hotspot network through wireless. In this case, they have no access to Internet but the java webstart mechanism try to download the JNLP in despite of this. In this case, JWS downloads the HTML login page and put it in its cache without any check. In consequence, the next access through shortcut is impossible.
Is it a known issue and is there a workaround?
Thanks in advance for your replies
FYI
We have removed the tag href from jnlp file and it's now ok. The jnlp is never updating but it's ok for us.
see, i am developing a web application that downloads files from a server via http requests, but in a case the file isn't in the server but in the applet itself, i mean, some binary content is dynamically generated inside the applet and it must be downloaded. Of course i can use the java libraries to save the file in the client file system (if the applet is a signed one), but i was wondering if it can be done connecting the java OutputStream to the browser's download window, in other words, start a download from an applet.
Am i a crazy person ?
by the way, is it possible to do something similar from javascript ?
No, it is not possible to get around security by attaching the output of an applet to the standard file download mechanisms of a browser.
OTOH, since the Next Generation Java Plug-In, it is no longer necessary to have a signed and trusted applet in order to save files(/bytes) to the local file-system. Chase the links in the Applet info. page for more details. For a demo. of using the JNLP API services (that the plug-in2 hooks into for this functionality) see the File service demo..
You can if e.g. you upload the file to the server and then force browser (via LiveConnect or otherwise) to open that file from the server.
As far as I'm aware, there's no cross-browser way to emulate downloading from within an applet. So you should create that download yourself, and let browser do what it does best.
Obviously, it might well make sense to move the actual creation of the stream to your server side.
One of my requirements is, on load of page, a file is to be created dynamically and downloaded at a particular location on the client's machine.
In case the file is already present, it has to be over written.
is there any way where we can access the client's system and store the file at the required folder?
I feel one cannot access the client machine when the code is being executed on the server..
Senorio:
1-User click on generate document then it took template stream data ,req. data file and then save two file into client machine.
2-After that template open and it fetch the data file from same directory.
Please help me on this. This is an SOS!!
There are probably other solutions, I use a signed applet for this purpose.
As always, there are a few caveats though:
You can't "force" anything against the will of the user. Applets may be disabled in the client's browser, or they may not even have Java installed. Or the target directory might not be writeable by the user.Your server should handle cases where the client doesn't have the correct version of the file gracefully.
You can't do this from the server side obviously but you also really can't do this from a client script either. Browser security will prevent a page script from modifying contents of the file system.
Your only options will be to run a third-party browser plugin software that has elevated permissions.
Examples of such are
Java Applets
Java WebStart
Microsoft Silverlight
ActiveX
Each one is different and most require some level of user interaction to confirm that they allow plugins to run with elevated security.
I am preparing a program in java and its purpose is to make the HttpWebRequest for a url which can open in any browser (i am planning to use watij for opening the page in different browser).Now my program should take the screen shot of the presently opened url once the page has loaded successfully.I need to run a piece of code after the browser has loaded successfully in the browser.I dont want to use the javascript document.ready function for identifying if the page is loaded successfully or not.I should be able to know the page load complete status in the server side (s0 that i can execute that piece of code for taking the screenshot).How can i do it in java.Or is there any other way to do achieve that if its not possible in java.May be create some plugins.
An early reply is highly valued,
Regards,Sagar.
you can do it using applet, [just taking snapshot i meant that you want.]
We have a web application that allows user to download a zip file from a web server. We just provide dummy iframe source to the full URL of zip file on web server. This approach would allow end user to use browser controls which allows the user to open or save the zip to user's local machine.
We have a requirement that the zip file is automatically extracted and save to a specific location on user's machine. Any thoughts on how this can be achieved?
Thanks.
I highly doubt that you'll be able to do that. The closest you're likely to get is to generate a self-extracting executable file (which would be OS-dependent, of course).
I certainly wouldn't want a zip file to be automatically extracted - and I wouldn't want my browser to be able to force that decision upon me.
Short answer is I don't believe this is possible using the simple URL link you've implemented.
Fundamentally the problem you have is that you have no control over what the user does on their end, since you've ceded control to the browser.
If you do want to do this, then you'll need some client-side code that downloads the zipfile and unzips it.
I suspect Java is the way to go for this - Javascript and Flash both have problems writing files to the local drive. Of course if you want to be Windows only then a COM object could work.
Instead of sending a zip file why don't u instruct the web server to compress all the web traffic and just send the files directly?
See http://articles.sitepoint.com/article/web-output-mod_gzip-apache# for example.