Pass a parameter from one jsp to another using form.action
Posted
by Ntz
on Stack Overflow
See other posts from Stack Overflow
or by Ntz
Published on 2009-08-05T16:49:23Z
Indexed on
2010/06/14
5:02 UTC
Read the original article
Hit count: 181
I have an ID that I need in the next jsp once the user click a button. I am trying to do the following:
FirstJSP.jsp:
function getSecond() { var frm = document.getElementById("frm"); frm.action = "**second.jsp?id=myId;"** frm.submit(); }... form id="frm" ..... input type="button" value="Next" onclick="getSecond()"/
......
This code takes me to my second page, but if I tried to access the id, it gives me an error since the id is null.
I access the id in the second page by:
final Long passedId = Long.parseLong(request.getParameter("id"));
I think I am not passing the parameter correctly, but I don't know how to do it. Any ideas? Thank you so much!
© Stack Overflow or respective owner