I am having a function which on calling window.open(URL),that URLis returning me a file. On clicking, once it's downloaded , i want to associate it with browser, means that file should only open in browser, but not with any default application preset by OS. Any leads on this is highly appreciated.
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.
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/
I have java code through which i set content type of excel and send it to browser. when ever it is downloaded using IE it shows open file dialogue which has OPEN,SAVE,CANCEL button.
I need to avoid this OPEN button and only show SAVE & CANCEL button, how to do this java.
I googled and found info that if we set meta type of contect in IE for download-option as noOPEN then this might be achieved; But i am not getting how to do this using java.
in java you can use
response.setHeader("X-Download-Options", "noopen");
this code for hide open button.
You can either render it inline by setting proper header
"content-disposition", "inline;filename=somefile.someExt"
or you can make it like attachment
"content-disposition", "attachment;filename=somefile.someExt"
in which case browser has its own way to prompt user, you can't change it [unless your browser provides some sort of setting that your client can set]
I am currently implementing a webview that uses the default behavior of opening the browser. When the page loads in the browser and I click the download link that is on the page that was loaded, the download starts, and quickly fails. I guess its an unsupported file type. How would I go about setting the WebView so that I may handle when a user downloads a file, and process the file myself? The reason I am going through a webview is that using httpclient, I was unable to spoof the headers after trying unsuccessfully for 30 or so hours. So what I would like to be able to do is handle the saving, and unzipping of the file myself. Can anyone write me some code to get started?
Thanks a million.
I am using
java.awt.Desktop.getDesktop().browse(uri);
to show my users a generated html file. All is fine if the browser (firefox 3.5.7; linux) is started before I make the call. But if the browser start is triggered from the getDesktop().browse call then the java application will not exit until the browser closes.
How can I avoid this behaviour? Is this known under windows/macOsx too?
(If I then force the exit of the java application the browser will close too and sometime even crash!?)
The reason the browser exists is because the browser is launched as a dependent process...so when the first process shuts down, all its dependent processes are shut down with it. But in the case when you start the browser first, it already has a different process ID that isn't affected by your application. I think the only way to avoid this behavior is to use a different technique (perhaps Runtime.exec()?) to launch the browser in a way that registers it as a non-dependent process.
The project Browser Launcher (http://browserlaunch2.sourceforge.net/) can be the solution for your problem. You can launch a browser from your code like this:
String url = "http://....";
BrowserLauncher() launcher = new edu.stanford.ejalbert.BrowserLauncher();
launcher.openURLinBrowser(url);