I have a Google App Engine servlet, it’s supposed to go to my site and get a file, then display the content of that file on the servlet served page, the code looks like this :
public class My_Servlet extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
System.gc();
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException
{
PrintWriter out=response.getWriter();
response.setContentType("text/html");
out.println(getTextFile());
}
String getTextFile()
{
String Text="";
try
{
URL url=new URL("http://example.com/A_Dir/Test.txt");
BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line=reader.readLine())!=null) { Text+=line+"<Br>"; }
reader.close();
}
catch (Exception e) { }
return Text;
}
It worked, but the problem is, after I changed the content in the file “Test.txt” on my site, the Google App is still displaying old data, I checked and double checked the file on my site, the old data is no longer there, and I thought every time I clicked the link served by the GAE, it will call getTextFile(), create the URL, go get the file and parse the lines, but it seems GAE is remembering old data from 3 days ago, and no matter how many times I refreshed the page or updated the GAE app and reloaded it on to the App Engine [and I can see the change made to the updated servlet], it’s still serving the more then 3 day old data, why? How to force it dynamically load that file?
GAE is caching the file. Try: