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 6670157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:14:07+00:00 2026-05-26T03:14:07+00:00

When developing a JSP application it’s possible to define a session timeout value, say

  • 0

When developing a JSP application it’s possible to define a session timeout value, say 30 minutes.

After that timeout, the session object is destroyed.
Moreover I can programmatically invalidate a session calling session.invalidate() .

Since I’m saving a complex Java object inside the HTTP session, before invalidate the session or let it expire by the tomcat app server, I need to call a saved object method to release some memory. Of course I can do it programmatically when the user click a logout button.

What I would like to do is intercepting the Tomcat app server when it is going to destroy all expired sessions (30 minutes or custom), so that I can pre-process Java objects saved in the session calling a specific method to release memory.

Is it possible?

  • 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-05-26T03:14:07+00:00Added an answer on May 26, 2026 at 3:14 am

    Yes, that’s possible. You could use HttpSessionListener and do the job in sessionDestroyed() method,

    @WebListener
    public class MyHttpSessionListener implements HttpSessionListener {
    
        @Override
        public void sessionDestroyed(HttpSessionEvent event) {
            // Do here the job.
        }
    
        // ...
    }
    

    Or you could let the complex object which is been stored as a session attribute implement the HttpSessionBindingListener and do the job in valueUnbound() method.

    public class YourComplexObject implements HttpSessionBindingListener {
    
        @Override
        public void valueUnbound(HttpSessionBindingEvent event) {
            // Do here the job.
        }
    
        // ...
    }
    

    It will be called whenever the object is to be removed from the session (either explicitly by HttpSession#removeAttribute() or by an invalidation/expire of the session).

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

Sidebar

Related Questions

I am developing a web application using Java/JSP. One class, say Student, has a
I have this application I'm developing in JSP and I wish to export some
Hi I am developing my application in flex and JSP, so when I am
I'm developing a jsp/serlvet application. I have a page with a list of inputs
I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
I'm developing a java servlet web application that manages information from multiple databases (all
Developing an application for Android, i want to record data that will be usefull
I'm developing a JSP application, and I want to be able to upload the
Im developing a web application(J2EE,Struts2,JSP,Tomcat) I want to hide the .jsp extension from webpages.
I am developing a small email web application in JSP/Javascript/html. It has a logout

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.