|Home |Login |Registration |Struts Step by Step Tutorial |Hibernate Step by Step Tutorial |Spring Step by Step Tutorial |JSP Step by Step Tutorial |JDBC Step by Step Tutorial |Web Services Step by Step Tutorial |EJB fundamentals | ORACLE Step by Step Tutorial | SCJP 5.0 and SCJP 6.0 Study Guide | SCWCD 5.0 Study Guide | SCJP Tips
Java mock test | SCJP mock test | SCJP DUMP | SCBCD mock test |Java online test exam | JSP online test | ORACLE online test | Hibernate online test | Servlet online test | Struts online test | EJB online test | C online test | C++ online test | Aptitude online test

Java interview questions | JSP interview questions | ORACLE interview questions | Hibernate interview questions | Servlet interview questions | Struts interview questions | JDBC interview questions | C/C++ interview questions | Spring interview questions | JMS interview questions | Informatica interview questions | EJB interview questions | OOPS and Design Pattern interview questions
1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc) JobsJobs and Walkins

 

Recent Questions

!!! JSP Frequently Asked Questions !!!

Q. How to add and delete Cookie in jsp ?

SCWCD 1.5 Exam Kit

!!!Answer!!!- From Technical Expert

Add Cookie to response object:
Cookie cookie = new Cookie ("name",value);
cookie.setPath("/");
cookie.setDomain(DOMAIN_NAME); DOMAIN_NAME may be .techfaq360.com
cookie.setMaxAge(2* 7 * 24 * 60 * 60);// 2 week
response.addCookie(cookie);

Get cookie from request object :

Cookie myCookie = null;

Cookie cookies [] = request.getCookies ();
if (cookies != null)
for (int i = 0; i < cookies.length; i++)
{
if (cookies [i].getName().equals ("name")) // the name of the cookie you have added
{
myCookie = cookies[i];
break;
}
}

Delete Cookie:

You can't delete the cookie. just add maxage to 0;
cookie.setMaxAge(0);
cookie.setPath("/");
cookie.setDomain(DOMAIN_NAME);
response.addCookie(cookie);

cookie.setMaxAge(-1) means on browser close cookie will be deleted.

Answered By : null Replied Date : Mar 26 2012
Answer :


Answered By : null Replied Date : Feb 23 2012
Answer :


Answered By : null Replied Date : Jan 26 2012
Answer :


Answered By : null Replied Date : Jan 14 2012
Answer :


Answered By : null Replied Date : Jan 14 2012
Answer :


Answered By : null Replied Date : Jan 12 2012
Answer :


Answered By : null Replied Date : Jan 11 2012
Answer :


Answered By : null Replied Date : Dec 10 2011
Answer :


Answered By : null Replied Date : Nov 11 2011
Answer :


Answered By : null Replied Date : Nov 6 2011
Answer :


Answered By : null Replied Date : Oct 11 2011
Answer :


Answered By : null Replied Date : Oct 3 2011
Answer :


Answered By : null Replied Date : Sep 6 2011
Answer :


Answered By : null Replied Date : Sep 1 2011
Answer :


Answered By : null Replied Date : Aug 1 2011
Answer :


Answered By : null Replied Date : Jun 22 2011
Answer :


Answered By : null Replied Date : Jun 19 2011
Answer :


Answered By : null Replied Date : Jun 17 2011
Answer :


Answered By : null Replied Date : May 31 2011
Answer :


Answered By : null Replied Date : May 30 2011
Answer :


Answered By : null Replied Date : Apr 20 2011
Answer :


Answered By : null Replied Date : Apr 13 2011
Answer :


Answered By : null Replied Date : Apr 6 2011
Answer :


Answered By : null Replied Date : Apr 1 2011
Answer :


Answered By : null Replied Date : Mar 30 2011
Answer :


Answered By : null Replied Date : Mar 10 2011
Answer :


Answered By : null Replied Date : Mar 10 2011
Answer :


Answered By : null Replied Date : Feb 25 2011
Answer :


Answered By : null Replied Date : Feb 21 2011
Answer :


Answered By : null Replied Date : Feb 17 2011
Answer :


Answered By : null Replied Date : Jan 15 2011
Answer :


Answered By : null Replied Date : Dec 29 2010
Answer :


Answered By : null Replied Date : Dec 16 2010
Answer :


Answered By : null Replied Date : Dec 16 2010
Answer :


Answered By : null Replied Date : Dec 16 2010
Answer :


Answered By : null Replied Date : Dec 15 2010
Answer :


Answered By : null Replied Date : Dec 15 2010
Answer :


Answered By : null Replied Date : Nov 26 2010
Answer :


Answered By : null Replied Date : Nov 22 2010
Answer :


Answered By : null Replied Date : Nov 22 2010
Answer :


Answered By : null Replied Date : Nov 13 2010
Answer :


Answered By : null Replied Date : Nov 10 2010
Answer :


Answered By : null Replied Date : Nov 8 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 2 2010
Answer :


Answered By : null Replied Date : Oct 29 2010
Answer :


Answered By : null Replied Date : Oct 9 2010
Answer :


Answered By : null Replied Date : Sep 23 2010
Answer :


Answered By : null Replied Date : Sep 14 2010
Answer :


Answered By : null Replied Date : Sep 11 2010
Answer :


Answered By : null Replied Date : Sep 10 2010
Answer :


Answered By : null Replied Date : Sep 6 2010
Answer :


Answered By : null Replied Date : Sep 4 2010
Answer :


Answered By : null Replied Date : Sep 3 2010
Answer :


Answered By : null Replied Date : Sep 2 2010
Answer :


Answered By : null Replied Date : Sep 1 2010
Answer :


Answered By : null Replied Date : Aug 30 2010
Answer :


Answered By : null Replied Date : Aug 14 2010
Answer :


Answered By : null Replied Date : Aug 7 2010
Answer :


Answered By : null Replied Date : Jun 3 2012
Answer :


Answered By : null Replied Date : Aug 5 2012
Answer :


Answered By : null Replied Date : Aug 16 2012
Answer :


Answered By : null Replied Date : Aug 31 2012
Answer :


Answered By : null Replied Date : Sep 2 2012
Answer :


Answered By : null Replied Date : Oct 10 2012
Answer :


Answered By : null Replied Date : Oct 19 2012
Answer :


Answered By : null Replied Date : Nov 3 2012
Answer :


Answered By : null Replied Date : Nov 4 2012
Answer :


Answered By : null Replied Date : Nov 6 2012
Answer :


Answered By : null Replied Date : Nov 8 2012
Answer :


Answered By : null Replied Date : Nov 10 2012
Answer :


Answered By : null Replied Date : Dec 31 2012
Answer :


Answered By : null Replied Date : Jan 7 2013
Answer :


Answered By : null Replied Date : Jan 8 2013
Answer :


Answered By : null Replied Date : Mar 6 2013
Answer :


Answered By : null Replied Date : Apr 27 2013
Answer :


Answered By : null Replied Date : Apr 27 2013
Answer :


Answered By : null Replied Date : Apr 27 2013
Answer :


 

You can also contribute to this answer:

Your Name:
Answer:

 
Ask Question and get answer from Expert.
View Answers List from Expert.

The information you are posting should be related to java and ORACLE technology. Not political.