0

This is my hello-world application I just wrote.

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


    response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");   //Line1
//  response.setHeader("Content-Type", "text/html");  # Line-AAA
    PrintWriter out = response.getWriter();

    //out.print("Good days are here :)");
    out.println("<!DOCTYPE html>");
    out.println("<html>");
    out.println("<head>");
  //  out.println("<meta http-equiv=Content-Type content=text/html;charset=ISO-8859-1/>");
    out.println("<title>servlet demo");
    out.println("</title>");
    out.println("</head>");
    out.println("<body>Helloworld");
    out.println("</body>");
    out.println("</html>");
    response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");    //Line2
}

Here initially I hadn't written Line-AAA and hence the webpage was not getting displayed properly as is obvious and later I added the line and everything worked perfectly.

But later i tried commenting out #Line-AAA and found that it has no effect even after server restart. Searching on stackoverflow i found two solutionsto disable caching in Line1 and Line2 ,but both doesn't seem to work. Page is getting displayed properly even after commenting out Line-AAA.

It apparently doesn't create any problem for me at the moment, but I am curious to know how to properly stop this caching.

Thanks in Advance

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
codeLearner
  • 53
  • 1
  • 8
  • Did you clear browser cache? See also http://stackoverflow.com/q/49547 – BalusC Jan 03 '16 at 18:41
  • @BalusC Yes, I tried that too. Still to no avail. Actually i opened in different browsers , still no effect. Sorry for late reply, was travelling – codeLearner Jan 04 '16 at 18:25

0 Answers0