0

hi every one i am trying to get to web application exist in my computer through java fx web view :

public void start(Stage stage) throws Exception {
    WebView webView = new WebView();
    WebEngine engine = webView.getEngine();

    engine.load("172.0.0.0://HOWEB/documentation:8080");//loadContent("<html> href = C:/Users/kaisios/Desktop/attempt9000.html<\\html>");

    VBox vBox = new VBox();
    vBox.getChildren().addAll(webView);

    Scene scene = new Scene(vBox, 800, 500);
    stage.setScene(scene);
    stage.show();
}

but it does not load the content . NOTE: I have already run xamp server but i think the formula of the url is wrong

1 Answer 1

3

There are several things wrong with the URL:

  • The protocol: This is probably http. You need to specify the IP in the protocol part of the url instead
  • The loopback IP is 127.0.0.1 not 172.0.0.0
  • The port is specified right after the host, which in this case is the IP
  • The port may be incorrect (verify in your xampp control panel that the port used is indeed 8080)

the correct url (assuming the rest is correct; use your standard webbrowser to check first) is

http://127.0.0.1:8080/HOWEB/documentation

You could also use a file URL, if you don't want to run a server:

File file = new File("C:/Users/kaisios/Desktop/attempt9000.html");
engine.load(file.toURI().toString());

Listening to the onError event can help you identify the issue:

engine.setOnError(evt -> {
    Throwable error = evt.getError();
    if (error != null) {
        error.printStackTrace();
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.