I'm trying to assign a js variable to java's request or session and want to access it from the server side. I dont want the js variable to be passed on in the URL. Help me, I'm seeking for a solution.
Thanks in advance
I'm trying to assign a js variable to java's request or session and want to access it from the server side. I dont want the js variable to be passed on in the URL. Help me, I'm seeking for a solution.
Thanks in advance
JavaScript only runs on the browser, it has no connection to the database except for ajax type calls.
But, you can add data to the post request for example from javascript, and that would get to the servlet, which is probably your best solution.
But, this really depends on which javascript library you are using, though, for more details.
I'm not sure if I understood your question. But if You want asynchronously manipulate "objects in browser" from server it is not possible directly.
There are workarounds, search for reverse ajax.
It sounds like you need to review the difference between GET and POST variable submission. GET will put it in the address (exmple.com/index.html?var=6) and POST will not. After that you'll have to look at your js library to determine how to direct what the variable hooks up to.
The typical most simple way is to use hidden input fields and have your JavaScript fill those input fields with the values you need. When your form gets submitted the hidden input fields will be accessibel in your Java