New to learning JSP, and trying out passing data between two pages.
I'm wondering if it is possible to pass a javascript variable to session.setAttribute()
At the moment, I can pass a string of text through 2 jsp files like so:
JSP1:
<% String text = hello;
session.setAttribute(test, text);%>
JSP2:
var someText = <%=session.getAttribute(test)%>
which works fine.
However, is it possible to pass through a var
into session.setAttribute
instead? I store some data in a javascript variable and would like to send it across to the second JSP file.
So for example:
var number = 7;
<%session.setAttribute(test, number);%>
I've tried this out and I get the error number cannot be resolved to a variable
Thanks!