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?

  • 1
  • @JoshCaswell thanks, I didn't find those two. So maybe the correct approach would have been to flag or downvote the question for being too broad, even though that wouldn't have helped the asker much. After all, SO is not for "How should I go about implementing this requirement"-like questions.
    – abl
    Dec 7 '14 at 20:36
  • Your example here is a little different than those in the questions I linked. I think yours is fine as is.
    – jscs
    Dec 7 '14 at 23:12
  • Would have been fine without links, so it's fine with. Maybe not the best, but fine.
    – user1228
    Dec 8 '14 at 16:22

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 .