Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:20:41+00:00 2026-06-09T15:20:41+00:00

I have created cookie using document.cookie in a jsp page. In my servlet (remember

  • 0

I have created cookie using document.cookie in a jsp page.

In my servlet (remember its not a jsp page where I can use java script. Its a servlet), I am retrieving cookie value and after its use, I want to delete them. I dont want to delete the cookies by using expiry time. I want to clear off its values. So, I am doing cookie.setValue("");

But, when I check the cookie in my Browser, its still holding the value. Its not clearing off.

  1. How to clear off its value?
  2. Also, is there a way to clear off the cookie name? I know that there is no cookie.setName() function. So, any other means?

After clearing, basically I dont want a user to see the cookies in the browser.

Regards,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:20:42+00:00Added an answer on June 9, 2026 at 3:20 pm

    You can delete cookie in 2 ways, either in your Servlet (as a server-side code), or if your Servlet renders an HTML document, you may add an page onload event as javascript code.

    // Server-side Code

    @Override
    protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    
      // Your task here
    
      Cookie cookie = new Cookie("cookieName", "");
      cookie.setMaxAge(0); // To delete the cookie named "cookieName", set MaxAge to 0.
      response.addCookie(cookie); // You need to add this cookie to the response to tell the client (browser) that the cookie named "cookieName" must be deleted on the client (browser)
    
      // Your task here 
    
    }
    

    For the client-side cookie deletion, you may check this http://www.webdevelopmentcentral.net/2007/12/client-side-cookie-handling.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the scripts from here http://www.quirksmode.org/js/cookies.html and have successfully created a cookie..
Am using WAMP server for PHP development. I have created a cookie in my
I am creating a website using Java EE. I have created a table in
I have created a cookie using php and now I need to create a
I am using wordpress and have created a cookie in functions.php. My problem is
I have a JSP page that creates a treeview using jQuery treeview plugin. Now
I have my own asp.net cookie created like this: var authTicket = new FormsAuthenticationTicket(
Say I have a PHP script that creates a cookie that expires 10 days
I have created a JSP / servlets application running in Tomcat 7. It runs
I have created an android application that calls (using kSOAP library) a SOAP based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.