SLIP 1:
Design an
HTML page containing 4 options ,buttons(painting,drawing,singing and swimming)
and 2 buttons reset and submit. When the user clicks submit button , the server
response by adding a cookie containing the selected hobby and sends a message
back to client. Program should not allow duplicate cookie to written.
/* Slip1_2 :*/
<%@page contentType="text/html"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<form
action="Slip1.jsp" method="post">
<input
type="checkbox" name="id" value="Painting"><br>
<input
type="checkbox" name="id" value="Drawing"><br>
<input
type="checkbox" name="id" value="Singing"><br>
<input
type="checkbox" name="id" value="Swimming"><br>
<input
type="submit" name="submit" value="Submit">
<input
type="reset" value="Reset">
<%
Cookie c1 = new Cookie("p", "Paintaing");
response.addCookie(c1);
Cookie c2 = new Cookie("d", "Drawing");
response.addCookie(c2);
Cookie c3 = new Cookie("s", "Singing");
response.addCookie(c3);
Cookie c4 = new Cookie("sw", "Swimming");
response.addCookie(c4);
%>
</form>
</body>
</html>
/* Slip1 :*/
<%@page contentType="text/html"
pageEncoding="UTF-8"%>
<%
Cookie c[]
= request.getCookies();
for(int
i=0;i < c.length;i++)
{
Cookie c1 = c[i];
out.println("\nName : "+c1.getValue());
}
%>
No comments:
Post a Comment