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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:12:55+00:00 2026-06-12T16:12:55+00:00

Is it possible to dispose of objects that are stored in the session in

  • 0

Is it possible to dispose of objects that are stored in the session in struts2?

Some of the objects I would like to store in the session have resources that need to be released, but I can’t find a way to dispose of them cleanly when the session times out or is closed.

I realize that client-based solutions require a javascript timer, but I’m not worried about the client side right now. I just want to be able to clean the resources up on the server-side when the session times out.

I thought about checking the sessions (plural because there can be many concurrent sessions with different clients) on each request and performing late cleanup, but at that point the session map is already gone.

  • 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-12T16:12:56+00:00Added an answer on June 12, 2026 at 4:12 pm

    Found the answer from a coworker. Thanks for the suggestions.

    It appears the solution is to create a class that implements HttpSessionListener. This interface contains functions that are called when the session is created and destroyed. Then add:

    <listener>
        <listener-class>my.package.listeners.TestSessionListener</listener-class>
    </listener>
    

    To web.xml or your servlet configuration file.

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

Sidebar

Related Questions

Possible Duplicate: Who should call Dispose on IDisposable objects when passed into another object?
I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I
I have always known that all good programmers call Dispose on any object that
I'd like your opinion on the following subject: Imagine we have a method that
I am working on a class that deals with a lot of Sql objects
I've got a small hierarchy of objects that in general gets constructed from data
I have a C# app that needs to scrape many many pages within a
I have a MyForm that derives from System.Windows.Form.Form. MyForm handles the FormClosed event whose
I made this code outside the methods because I need to close and dispose
I have created a simple repository class that is returning a list of Projects:

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.