I have one JSP file as jsp 1.jsp and another JSP file as jsp 2.jsp
I\'ve included jsp 2.jsp in jsp 1.jsp>
You have a number of options:
Store it in the session.
// Memorise any passed in user.
String username = request.getParameter("username");
if (username != null && username.length() > 0) {
session.setAttribute("username", username);
}
Store it as a hidden field in the form.
Store it in a cookie.
username = getCookie(userCookieName);
// Get from cookie.
function getCookie(name) {
if (document.cookie) {
index = document.cookie.indexOf(name);
if (index !== -1) {
f = (document.cookie.indexOf("=", index) + 1);
t = document.cookie.indexOf(";", index);
if (t === -1) {
t = document.cookie.length;
}
return(document.cookie.substring(f, t));
}
}
return ("");
}
Persist it on the client side in sessionStorage. See here for details.
sessionStorage.setItem("username", "...");
Not really another option but a mechanism - pass it in the URL:
.... onclick="window.location='details.jsp?username=...'