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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:09:59+00:00 2026-05-22T02:09:59+00:00

I have a caching Servlet Filter, the filter will, for certain URLs, add a

  • 0

I have a caching Servlet Filter, the filter will, for certain URLs, add a Cache-Control: public, max-age=x header to responses.

But it shouldn’t publicly cache any responses that are setting any cookies. How do I check to make sure the response doesn’t have cookies set (including making sure the servlet container isn’t going to send a JSESSIONID)?

  • 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-22T02:10:00+00:00Added an answer on May 22, 2026 at 2:10 am

    You can use a HttpServletResponseWrapper:

    public void doFilter(..) {
       chain.doFilter(request, new Wrapper(response));
    }
    

    where the Wrapper extends HttpServletResponseWrapper, overrides the addCookie method, call super.addCookie(..) and sets a boolean to true, meaning a cookie has been added. That boolean can be either in a field of the wrapper or as request attribute. Either way you can read it later when you need to check if a cookie has been added.

    For jsessionid (appended to the URL) you can override the encodeRedirectURL, and check whether the call to super.encodeRedirectURL(..) will append the jsessionid

    But not caching a resource that is sending a session cookie might be wrong. Any resource might send a session cookie, if it is the first one to open.

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

Sidebar

Related Questions

I have a asp.net web forms app that uses System.Web.Caching.Cache to cache xml data
Do any of the currently popular browsers have particular problems caching* XMLHttpRequest responses that
In Yii, I have enabled APC caching through the config/main.php file: 'cache' => array(
As the header states, have I understood caching correct, and if so does anyone
I have output caching implemented at controller level [OutputCache(CacheProfile = MyProfile)] public Result MyControllerAction()....
In particular what strengths does it have over caching features of Asp.net
I have a file caching system for a php application. if a file needs
Since version 1.5 Subversion supports to have a local caching-proxy for the main Master-repository.
I have read the documentation for the CI Caching but still don't understand much
I have read lots of information about page caching and partial page caching in

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.