0

I am trying to use javaFx for my application. I have a java server tested and running code, actually its a library that initiates server. I have problem loading file from javafx's webview. Suppose the server is running on port 2345 then the following shows javafx's webview blank.

-- some code ---

Webview view  = new Webview();
view.getEngine().load("http://localhost:2345/sample.html");

---- some code ---

The content loads fine from the web browser but not from the javaFx webview. What is preventing webview to load content/file ? My guess was that the webview load is instantiated before the server is started, so I worked with javaFx runLater but it didn't solve. Any help will be appreciated?

Kushal
  • 98
  • 12

1 Answers1

0

If you have server with http through port 2345 you need to state it's name in advance to port:

"http://servername:2345/sample.html"

e.g. if you have server on the same machine:

"http://localhost:2345/sample.html"
Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141
  • That's true, i 've been doing that...but still nothing. – Kushal Feb 22 '15 at 08:39
  • Can you please elaborate "webview doesn't load"? White screen? Can it load other sites in your program? – Sergey Grinev Feb 22 '15 at 08:56
  • Yes i can load other sites from my program but i can't load localhost on some port started by server, but i can load the same url from browser... – Kushal Feb 22 '15 at 09:42
  • 1
    Well the WebView was expecting the complete response from the java server. It was expecting Content-Type: text/html as well but the browser could understand without that. It took me a while to figure out. Hope this helps . Thanks for answering my question. – Kushal Mar 02 '15 at 17:16