We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
Practical Exam Questions
; _-
‘Ti]Write a program to create cook
import Javax.serviet.nttp.";
WebServiet("/cookieDemo")
public olass Cookie extends HttpServiet {
protected void doGet(HttpServietRequest ri
throws ServietException, [OException {
| Set the content type
response.setContentType("text/htm!”
|; HttpServi
Response resp)
| Greate a cookie
username”, "JohnDoe")s
cookie.setMaxAge(60 * 60}; // Set cookie to expire in 1 hour
response.addCookie(cockie); |! Add the cookie to the response
i Write a response
resp.getWriter().printin(""
resp.getWriter().printin("“