|
INTERVIEW QUESTIONS
J2EE
JSP
DETAILS
Question: How can I set a cookie and delete a cookie from within a JSP page?
Answer: A cookie, mycookie, can be deleted using the following scriptlet:
<% //creating a cookie Cookie mycookie = new Cookie("aName","aValue"); response.addCookie(mycookie); //delete a cookie Cookie killMyCookie = new Cookie("mycookie", null); killMyCookie.setMaxAge(0); killMyCookie.setPath("/"); response.addCookie(killMyCookie); %>
|
|
|
Category |
JSP Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 8850 users |
Added on |
10/24/2009 |
Views |
75946 |
Rate it! |
|
|
Question:
How can I set a cookie and delete a cookie from within a JSP page?
Answer:
A cookie, mycookie, can be deleted using the following scriptlet:
<% //creating a cookie Cookie mycookie = new Cookie("aName","aValue"); response.addCookie(mycookie); //delete a cookie Cookie killMyCookie = new Cookie("mycookie", null); killMyCookie.setMaxAge(0); killMyCookie.setPath("/"); response.addCookie(killMyCookie); %> Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How can I declare methods within my JSP page?
|
View Answer
|
|
How can I enable session tracking for JSP pages if the browser has disabled cookies?
|
View Answer
|
|
How do I use a scriptlet to initialize a newly instantiated bean?
|
View Answer
|
|
How does JSP handle run-time exceptions?
|
View Answer
|
|
How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
|
View Answer
|
|
How do I use comments within a JSP page?
|
View Answer
|
|
Can I stop JSP execution while in the midst of processing a request?
|
View Answer
|
|
Is there a way to reference the "this" variable within a JSP page?
|
View Answer
|
|
How do I perform browser redirection from a JSP page?
|
View Answer
|
|
What JSP lifecycle methods can I override?
|
View Answer
|
|
Can a JSP page process HTML FORM data?
|
View Answer
|
|
How do I mix JSP and SSI #include?
|
View Answer
|
|
How can I implement a thread-safe JSP page?
|
View Answer
|
|
How do I include static files within a JSP page?
|
View Answer
|
|
How do you prevent the Creation of a Session in a JSP Page and why?
|
View Answer
|
|
What is the page directive is used to prevent a JSP page from automatically creating a session?
|
View Answer
|
|
Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?
|
View Answer
|
|
Can a JSP page instantiate a serialized bean?
|
View Answer
|
|
Can you make use of a ServletOutputStream object from within a JSP page?
|
View Answer
|