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

  • Home
  • SEARCH
  • 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 9001179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:24:07+00:00 2026-06-16T00:24:07+00:00

For a Java JSP web application I’m making, I keep an object in a

  • 0

For a Java JSP web application I’m making, I keep an object in a session.
If there are multiple users signed onto the site, each in their own session, I would like for all the session (regardless of when they started) to expire at midnight the same day.

For instance:

session object 1: creation date (2012-12-11 8:45), expiration date (2012-12-12 0:00)

session object 2: creation date (2012-12-11 12:00), expiration date (2012-12-12 0:00)

And so on, every day the day’s sessions getting invalidated.

Some ideas I had was

  • to set the session’s time until expiration to (the next midnight – the current date), though I’m not entirely confident in my ability to progrematically do this
  • schedule some kind of server task to clear all the sessions at midnight every day

What is the best way to go about this?

  • 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-16T00:24:07+00:00Added an answer on June 16, 2026 at 12:24 am

    The best way I see is Option 2

    1. Implement a HttpSessionListener – http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpSessionListener.html – this will help you collect the active sessions in a Collection using call back methods sessionCreated() and sessionDestroyed().
    2. Use a TimerTask – http://docs.oracle.com/javase/6/docs/api/java/util/TimerTask.html that runs every midnight and closes all the active sessions you have collected.

    Option 1 is also possible but might be little unpredictable as you have to set a precise timeout every time you create a new session.

    Have fun !

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

Sidebar

Related Questions

i have made a small web application with form.html output.jsp ServletOne.java In the form.html,users
Hi I have a page in my java/jsp based web application which shows list
My web application is written using jsp/javascripts. Backend Java. Have managed to implement the
im planning to use java/jsp for web application installed on virtual web hosting space
I am using Java servlets and JSP in my web application. My question is
When running a java web application with the servlet api (like JSF or JSP
I'm developing a java servlet web application that manages information from multiple databases (all
I'm working on an existing Java web application (HTML/CSS/JS/JSP/Servlets and Java classes in this
I have a regular JSP/Servlet/Java web application that is used for uploading pictures from
I am building a web application using java servlets and jsp. Every thing is

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.