Is it possible to set some values to the localStorage in HTML5 from Java class, without going to the xHtml Page.
Currently i can set using javascript.
Is it possible to set some values to the localStorage in HTML5 from Java class, without going to the xHtml Page.
Currently i can set using javascript.
No it is not possible. Local storage is a client side feature. So unless you are using GWT (there is a Storage
class) there is no way to set it from Java.
Please note however that there are many tools/services out there that allow you to synchronize your back-end store with HTML5 storage such as Firebase. You can find additional information on that matter here: Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync) and here: How to synchronize HTML5 local/webStorage and server-side storage?
It is not possible to set client-side local storage from server-side code. The closest thing to that is a cookie (sort of, but not really), which still requires a request to be made. You will have to use JavaScript as you are currently doing. You can still have the server generate the data you wish to store (using any number of various means, e.g. generating JavaScript, making AJAX style async requests for data, etc.).