Maintain the value in textbox with JSP
Hi,
I am having two JSP's. one is A.jsp, another is B.jsp.
A.jsp which is having two text boxes like name and age.
once i have entered the values for name and age it will should go the B.jsp and it should come back to the A.jsp that time the value i have entered should be in that text boxes only.
How to do that
Thanks in Advnace
One way is to store the values in session variables. You can take that values whenever you want as long as the session is there.
index.jsp
<html>
<%
String username = "";
String password = "";
if(request.getParameter("Login") != null) {
session.setAttribute("username", request.getParameter("username"));
session.setAttribute("password", request.getParameter("password"));
response.sendRedirect("home.jsp");
}
else if(request.getParameter("Back") != null) {
username = session.getAttribute("username").toString();
password = session.getAttribute("password").toString();
}
%>
<form id="index" action="index.jsp" method="post">
<table border="1">
<tr><td>User Name : </td><td><input type="text" name="username" value=<%=username%>></td></tr>
<tr><td>Password : </td><td><input type="password" name="password" value=<%=password%>></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="Login" value="Login"></td></tr>
</table>
</form>
</html>
home.jsp
<html>
<table border="1">
<tr><td><a href="index.jsp?Back=true">Index</a></td></tr>
</table>
</form>
</html>
Cheers