Cache does not clear when invalidating the session while object data do

I have three servlets that handle login, display some data and log out each.

In the login servlet in the doPost method I initialize my session with this code

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> HttpSession session = request.getSession();
session.setAttribute("UserObject", customer);
response.sendRedirect("MainServlet");
</code>
<code> HttpSession session = request.getSession(); session.setAttribute("UserObject", customer); response.sendRedirect("MainServlet"); </code>
 HttpSession session = request.getSession();
 session.setAttribute("UserObject", customer);
 response.sendRedirect("MainServlet");

In the Main servlet I have this code in the doGet method:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>User user= new Seller();
HttpSession session = request.getSession(false);
if (session != null && session.getAttribute("UserObject") != null) {
System.out.println("Success on session");
user = (User) session.getAttribute("UserObject");
}
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies
</code>
<code>User user= new Seller(); HttpSession session = request.getSession(false); if (session != null && session.getAttribute("UserObject") != null) { System.out.println("Success on session"); user = (User) session.getAttribute("UserObject"); } response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1 response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setDateHeader("Expires", 0); // Proxies </code>
User user= new Seller();
HttpSession session = request.getSession(false);
if (session != null && session.getAttribute("UserObject") != null) {
       System.out.println("Success on session");
       user = (User) session.getAttribute("UserObject");
}
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies

This code populates some data of the user object but also fills some tables from a DataBase.

And in the doPost method when I want to logout I have this code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>out.println("<form action="LogOut" method="get">n" +
" <input type="submit" value= "LogOut">n" +
"</form>");
</code>
<code>out.println("<form action="LogOut" method="get">n" + " <input type="submit" value= "LogOut">n" + "</form>"); </code>
out.println("<form action="LogOut" method="get">n" +
"  <input type="submit" value= "LogOut">n" +
"</form>");

Finally, the logout servlet in the doGet method has this code for invalidating the session:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies
response.sendRedirect("index.html");
</code>
<code>HttpSession session = request.getSession(false); if (session != null) { session.invalidate(); } response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1 response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.setDateHeader("Expires", 0); // Proxies response.sendRedirect("index.html"); </code>
HttpSession session = request.getSession(false);
if (session != null) {
     session.invalidate();
}

response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setDateHeader("Expires", 0); // Proxies
response.sendRedirect("index.html");

Problem is that the invalidation happens successfully for the object’s data but not for the data loaded with the database (cashed maybe?). Before invalidating there is a table with the user’s name and surname, loaded by the object’s attributes and a table with data loaded by a database. After logging out/invalidating and pressing the back button on the browser the data about the object are set to null correctly, but all the data filled by the database is still there. The caching does not seem to go away.

Even when trying from a fresh browser all the data is kept there. What’s a solution?

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật