<!DOCTYPE html>

<!--

To change this license header, choose License Headers in Project Properties.

To change this template file, choose Tools | Templates

and open the template in the editor.

-->

<html>

    <head>

        <title>JSP program for Users</title>

        

    </head>

    <body>

        <form action="http://localhost:8080/JspPrograms/users.jsp" method="GET">

Username : <input type="text" name="username" size="40" />

<br >

Email    : <input type="text" name="email" size="50" />

<br>

Mobile No: <input type="number" name="mbno" />

<br>

<input type="submit" value="Submit" />

</form>

        

    </body>

</html>


output:



source file name: users.JSP

<%
         
   Cookie username = new Cookie("username", request.getParameter("username"));
   Cookie email = new Cookie("email", request.getParameter("email"));
Cookie mobile = new Cookie("mobile", request.getParameter("mbno")); 
   
   username.setMaxAge(600); 
   email.setMaxAge(600);
   mobile.setMaxAge(600);
 
   // Add both the cookies in the response header.
   response.addCookie( username );
   response.addCookie( email );
%>
 
 
<html>
<head>

<title>JSP Cookie Program</title>
</head>
<body>
 
<b>Username:</b>
   <%= request.getParameter("username")%>
   <br>
<b>Email:</b>
   <%= request.getParameter("email")%>
   <br>
   <b>Mobile no:</b>
   <%= request.getParameter("mbno")%>
 
</body>
</html>

output: