Depending on the need, I think it will be clever to have some hidden text field then make assign the Javascript variable as the value for your hidden field which could be assessed later by the JSP/Servlets.
Paul Okeke wrote:Depending on the need, I think it will be clever to have some hidden text field then make assign the Javascript variable as the value for your hidden field which could be assessed later by the JSP/Servlets.
Except that I assume he's talking about accessing the value in the same JSP that generates the page -- which is, of course, impossible.
There is no direct way but using some javascript and ajax trick it is possible. If if you have several use cases like that you can build a jsp which will be called via ajax. In the url pass this javascript variable as parameter. Get this parameter from request in that new JSP and put it in session. But this trick may not be applicable to all use cases. The better way is to redesign the way you are currently building the page. Think different.