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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:54:45+00:00 2026-05-18T00:54:45+00:00

So I need to add a filter to a spring app, such that after

  • 0

So I need to add a filter to a spring app, such that after the response has been flushed back to the client, I write to a log file. The values I want to write to the log file are determined within the app. In other words, I would like to pass values, ideally a hashmap of values, to the filter that sits after the main processing has completed.

Is there a best practice way of doing this? I could imagine that I could instantiate the hashMap in the filter when the request first comes in, stash that hashmap somewhere (where?), retrieve it in the app and write to it, and then retrieve it again in the exit filter and write the value out. Is that the best practice way to do it, and if so:

1) Do I have just one filter that fires on entry and exit or do I need to set up two, one for before the app and one for after?

2) Where is the best practice place to stash my data store?

  • 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-18T00:54:46+00:00Added an answer on May 18, 2026 at 12:54 am
    1. One filter is enough. In filter

      //Before calling the servlet. Do something

      chain.doFilter(request, wrapper);
      

      //After servlet completes processing. Retrieve data here.

    2. Consider ThreadLocal variables. I am not sure if this is best practice. You will store data in servlet and retrieve in filter (after ‘chain.doFilter()’. But make sure that you clean up the data stored in ThreadLocal before the request is complete because server pool threads so your data in thread locals may not be cleaned.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to AJAXfully filter by users list of PsDoctrans which is shown in
I've been assigned to build a questions & answers widget for my company. Many
This is my current code that does a MultiField Query ''# Variables used by
As the title says: in sharepoint 2010 i need to programmatically create a view
Is there any way I can filter my NHibernate query on the SubType field
I want to write a Scala script to recursively process all files in a
I try to explain my problem with a non-perfect english :) When i try
Now this is a trick question because you cannot do this: var a =
I have a single logger with multiple handlers, which have their own formatters. Now

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.