Results 1 to 3 of 3
  1. #1
    Sweety13 is offline Member
    Join Date
    Jan 2011
    Rep Power

    Default Help for logout and cookie

    ... I'm new to the forum and I hope to put this thread in the right section!
    I have to make a simple web application that is able to handle the log-in
    and log-off of a user, displaying a form of log-in if the user
    not 'authenticated, the home page and if'.
    Constraints of creation:
    - Use cookies to maintain login information.
    - Use other technologies ("Session" HTTP Java, for
    example) for maintaining session information.

    I created the application with eclipse / tomcat in Java
    I made an index.html page, where I enter the login form
    I created a servlet for login I check if user and pass are correct (with reference to a static database), displaying a homepage where the user is in database, if no error is present.
    In this servlet HttpSession session and I used a counter to see how many times a user views the section ... so far so good ...
    but how do I log out
    I tried to put this code in homepage.html:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Home Page</title>

    <h1> Benvenuto </h1><br><br>
    <p>Operazioni disponibili</p>
    <li>Scrivi un commento</li>
    <li>Cerca un articolo</li>

    <form action="ServletLogout" method="post">

    and to build a servlet using session.invalidate logout ()
    ... .. but still keep the session open even if I log out ... HOW DO I ?!?!!?
    And where / how to put COOKIE?!?!

  2. #2
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Rep Power


    - put logout on achor tag
    - once log out is clicked ...redirect page to whateva u page u want to redirect.
    - use session.invalidate() or response.getSession().invalidate()

  3. #3
    Sweety13 is offline Member
    Join Date
    Jan 2011
    Rep Power


    thanks for the reply!:)
    I resolved then:)
    ... but the cookies to maintain login information, where should I put them? in servlet login? is there any example of the syntax ...
    Thanks and good day to all

Similar Threads

  1. Creating cookie ?
    By Char in forum Networking
    Replies: 8
    Last Post: 12-25-2010, 07:10 PM
  2. Setting domain of cookie
    By mintyzzz in forum Java Servlet
    Replies: 1
    Last Post: 10-23-2010, 04:29 AM
  3. Remove cookie
    By erakhman in forum Java Servlet
    Replies: 1
    Last Post: 08-09-2010, 11:16 AM
  4. Browser Cookie Access
    By OrangeDog in forum Java Applets
    Replies: 1
    Last Post: 04-28-2009, 04:44 AM
  5. Setting cookie from doPost
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-25-2008, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts