I am trying to use javascript to do something once it detects a change in the session object. However, javascript does not detect the change in the session object after i have called UpdateServlet. All these is done on the same page (ie. there is no refreshing of page)
Please help! Thanks.
index.jsp
<%
//initial settings
session.setAttribute("dataUpdated", "false");
%>
<script>
$(function() {
var updates = '<%=session.getAttribute("dataUpdated")%>';
alert(updates);
//Shows false even after update
if (updates=="true"){
//alert("Updated");
}
});
</script>
UpdateServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
session.setAttribute("dataUpdated", "true");
//session object set to true
}