Ajp Exp 8
Ajp Exp 8
Experiment 8: Implement cookies to store firstname and lastname using Java server pages.
Form.jsp
<!DOCTYPE html>
<html>
<head>
<title>Form Page</title>
</head>
<body>
<form action="saveName.jsp" method="post">
First Name: <input type="text" name="firstName"><br>
Last Name: <input type="text" name="lastName"><br>
<input type="submit" value="Submit">
</form>
</body>
saveName.jsp code:
response.addCookie(firstNameCookie);
response.addCookie(lastNameCookie);
response.sendRedirect("showName.jsp");
%>
showName.jsp code:
}
}
%>
<!DOCTYPE html>
<html>
<head>
<title>Show Name</title>
</head>
<body>
<h2>First Name: <%= firstName %></h2>
<h2>Last Name: <%= lastName %></h2>
</body>
</html>
Output :