I am setting data in session attribute after fetching from DB once user is logged in. But when user reloads the page, I want the session attribute to be updated with the latest data from DB so that updated data is displayed on the screen using
<c:forEach items= "${sessionScope.allPosts}" var="post">
...
</c:forEach>.
It is basically just 2 lines of code in Servlet where PostsDao.getPosts()
will fetch the latest data:
List<Post> allPostsList = PostsDao.getPosts("ALL", userId);
session.setAttribute("allPosts", allPostsList);
How do I make this call every time when user click on page refresh?