function saveToSession() {
var name = document.getElementById('name').value;
var mobile = document.getElementById('number').value;
sessionStorage.setItem("name", name);
sessionStorage.setItem("mobile", mobile);
document.getElementById("leadForm").action = "/validate";
document.leadForm.submit();
}
After the validation, I need to display the saved name
and mobile
on another JSP page along with an additional attribute selected on the previous page.
I am struggling with passing session values from JavaScript to JSP.
In my JSP page, I have tried:
String storedName = (String) session.getAttribute("name");
out.println(storedName);
However, I keep receiving a value of null
.