I am developing a web project in which i call one Java class which updates the XML file and then i redirect the request to a JSP which displays the contents of that updated XML file. But the updated XML values are not being displayed until i manually refresh the folder which contains that XML file.
Template of my code is..
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String instanceName=request.getParameter("instanceName");
int no_of_days=Integer.parseInt(request.getParameter("days"));
CopyOfUpdateXmlLicenses obj2=new CopyOfUpdateXmlLicenses(instanceName, new_free_lic);
obj2.updateXML_Licesnes();
long time=new Date().getTime();
response.sendRedirect("Licenses.jsp?ms="+time);
}
Thank you all for spending your time on my question.
I found the root cause for the above mentioned problem.
There’s no problem with the code, rather with the Eclipse IDE.
The IDE takes some time to refresh the contents of the workspace. So in the mean time, if our program tries to read the contents of a file which is in the workspace, the changes may not get reflected immediately.
So try to check the web application by deploying it onto tomcat.
If you want to execute it in the Eclipse IDE, then go to window-> preferences->general->workspace and select the option “refresh automatically.“