Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Servlet + cookies ( Tomcat )

  • 20-03-2003 07:48PM
    #1
    Closed Accounts Posts: 1,719 ✭✭✭


    hi i have a slight problem. i am writing a servlet to login a user to a site. once the user is authenticated i send them a cookie. this cookies just stores some info.

    now here's the problem,once the cookie is sent to the client,how do i delete the cookie from them?

    currently i have a simple while loop that puts all the cookies into an array and blanks all the names and values.
    BUT this is the problem. the loop just adds cookies with a null name and value to the client.

    so my question is: how do i delete or blank the name and value of a cookie i sent to a client

    ohh and the cookie's expire when the session ends.


Comments

  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭Zab


    Why are you doing it like this? What I mean is, Tomcat will handle the session cookie for you, which will just contain a session ID. Then you can just use the session object in your servlet code to store various bits of information.... and they will all be defreferenced when the Tomcat kills the session. This way you can store all the information on the server, rather than the client ( except for the session ID ).

    Zab.

    PS: Tomcat also has authentication in it, which may be worth having a look at.


  • Closed Accounts Posts: 1,719 ✭✭✭Ruaidhri


    it's for a project.
    i want to authenticate users against a database of users. this is why i'm doing it this way.

    i'm only using tomcat to serve out the servlets and jsp's,nothing else.


Advertisement