Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing HTML DOM elements from Java

I'm developing (with Java) a P2P application. One of the features includes a chat service. When a user sends a message to all of the application users, each user gets the message and updates its chat HTML page.

How can I access, from my Java code, the DOM of this page and change it, without the need to refresh the page in order to see the new message?

Is there any object in Java that can get me this access? For example, can I call a JavaScript function that inserts the new message?

like image 949
tomericco Avatar asked Nov 27 '25 00:11

tomericco


1 Answers

If by from Java you mean applet then: You can define some javascript functions in your HTML page to return/modify what you want and then call the javascripts from the applet. Look at here.

If by Java you mean Web server then you have to use some AJAX solution, you can look for example at JQuery

like image 157
lujop Avatar answered Nov 29 '25 13:11

lujop