1

I will be creating a ServletFilter that will alter the way HTTP Requests are processed.

The ServletFilter will make those decisions based on the state of the data in the database.

I would rather not have a database hit happen every time the ServletFilter is invoked.

The webapp already has quartz implemented, so hitting the database at a predetermined time is not a problem.

My question is, how can I contact the ServeltFilter at these timed intervals to give it a new set of saved information until the next timed interval?


Update: There is useful discussion in this SOF post about getting a ServletContext into a Quartz job. How to get and set a global object in Java servlet context

Community
  • 1
  • 1
Steve
  • 3,127
  • 14
  • 56
  • 96

2 Answers2

1

The short answer is: Yes you can, but though I would not recommend it, since your update functionality should not be located there but in a class responsible for that task, this improves cohesion.

Hope you find this helpful.

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
1

Instead of trying to find the Filter to tell it, have the Filter look the information up by querying a service somewhere (e.g. stored in the ServletContext), or just have the service store the information in the ServletContext.

Christoffer Hammarström
  • 27,242
  • 4
  • 49
  • 58