I have a simple HTML page printed out inside a Servlet. Here I have setup firebase admin sdk and have set a value event listener for a path.
When the events fire, I wish
With servlets, your clients won't see any page updates until they send a new request to your application server. What you can do is get your ValueEventListener
to update the state of an in-memory object. Then your servlet can read the latest state of that object whenever constructing the HTML output.
So i managed to solve this using a JSP instead of a Servelet.
In either case, the solution was to tranfer all the logic to a JavaScript function. Then calling the said function on body load.
onload=callthefunction()
The firebase listeners were converted from java to the JavaScript version:
on()
off()
This way there is need to call ajax or anything and the elements that need to be changed can be directly altered from JavaScript