leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
445 stars 21 forks source link

Feature request support originating HTTP URLs #112

Closed ghost closed 3 years ago

ghost commented 3 years ago

I trying to run a little example on http://foo/bar.html and the Java code makes a connection to http://foo/baz.rsc . But URLConnection will refuse to work. I investigated a little bit. It seems that the CheerpJ runtime only

installs a virtual file system that allows access over /app which does HTTP requests under the hood, but it seems it doesn't install an URLConnection factory. Are there versions of CheerpJ that also provide an

preconfigured URLConnection factory?

alexp-sssup commented 3 years ago

I think this answer your question: https://github.com/leaningtech/cheerpj-meta/wiki/Frequently-Asked-Questions#my-java-application-needs-to-get-data-over-the-network-but-i-only-get-socketexceptions

ghost commented 3 years ago

It says, and I will try it, hopefully it works:

In the browser environment it is not possible to use sockets to connect to arbitrary ports. As a special exception CheerpJ provides a custom HTTP/HTTPS handler (based on XHR) that can be used to get data over HTTP and use REST APIs.

To enable this handler please set the property java.protocol.handler.pkgs= com.leaningtech.handlers during the cheerpjInit call, for example:

cheerpjInit({javaProperties:["java.protocol.handler.pkgs=com.leaningtech.handlers"]});
ghost commented 3 years ago

Why isn't this enabled by default? Does it support GET with a query part? Or do I have to use POST? Do you have some more extensive documentation?

Anyway good thing I asked. Was already a little desperate. I hope there will be a happy ending!