13

I have recently written this answer:

Your problem has two distinct parts:

  1. How do I update user session attributes whenever I want to?
  2. How do I do something every 20 minutes?

For the first part, you just need to keep a collection of all current sessions that you can access from anywhere (i.e. without the need of having an HttpServletRequest). This is answered in this post: How do I get a list of all HttpSession objects in a web application?

For the second part, your best fit is probably a ScheduledExecutorService. See also: Running a Java Thread in intervals

As you can see, the only thing my answer does is decompose the original question in two and provide links for each one of them. I think it wouldn't make sense to write a complete (i.e. not primarily link-based) answer when the problems have been solved already in other posts. I also cannot flag the question as a duplicate because it isn't really a duplicate of any of the two posts. So my question is: is an answer like that acceptable or should it be considered bad for being link-only?

14

Seems reasonable to me.

It's worth noting here that you're adding value to the links you provide by explaining how they relate to the asker's question. That's considerably different from just posting a link (or closing as a duplicate), and makes a lot of sense when the real problem being faced by the asker is a struggle to break down a more complicated issue. This falls into "teaching the asker to fish" territory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .