java cookies omplementation

i need to send url to customers if he clicks it he has to go to that particular url with cookies tell me the exact way i can do along with clear coding
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cookies are set and read by the web server
to go to a URL, just use HTML
<a href='">Go to site</a>

Why do you want to use cookies?

Do you want persistant values sent to that URL?

Give us an example.
gopal_kgkAuthor Commented:
if i create a cookie and seting the cookie if particular cookie value it has to go to onejsp.jsp page if again the user using the same machine he will be going to the same page i need him to go to defaulpage  how how u will remove the existing cookie
gopal_kgkAuthor Commented:
i have set the cookies and get the cookies value ,but now i need to change the value of the cookies in to new value deleting the existing value in the jsp page how do we cahieve ..can u give code for it clearly
You don't need to delete the cookie, just reset the value:

   Cookie[] cookies=request.getCookies();
   Cookie myCookie=null;
   for(int i=0;i<cookies.length;i++) {
     if (cookies[i].getName().equals("MyCookie")) {
   if (myCookie==null) {//cookie not found, must be a new request
     myCookie = new Cookie ("MyCookie", "theCookieValue");
      // Expire in five minutes (5 * 60)
      cookie.setMaxTime( 300 );
      // Expire after the browser is closed
      // cookie.setMaxTime( -1 );

      // Expire right now
      // cookie.setMaxTime( 0 );  //This would delete the cookie)
  myCookie.setValue("New Value");


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.