English 中文(简体)
Jsp page not showing the content of amended xml file until i Manually re the /61/3er in which the xml is found
原标题:Jsp page not displaying the contents of modified xml file until i manually refresh the folder in which the xml is located

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.

我的法典有缩影。

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.

如果你想要在Eclipse IDE中执行,那么就去到window->偏好-> general->workspace,并选择“refresh”的选项。

问题回答

You re making a major design mistake. The webapp should not write to the deploy folder during runtime and well due to the following main reasons:

  • All changes get lost whenever you redeploy the WAR or restart the server. Simply because those changes are not contained in the (original) WAR.

  • Some servers does not expand the WAR on disk, but in memory instead. The getRealPath() would then return null, making you unable to write files to it.

你的具体问题是,因为你重新部署并管理一个民主选举学会的网络应用,从而造成了问题。 民主选举学会没有立即发现外部进行的项目组合结构的任何变化。 但是,你们应当认识到,民主选举学会不是一个服务器,也不是在生产环境中运行。 民主选举学会只是一种发展工具。

You need to write the file to a fixed path outside the deploy folder instead.

我将做一个叫做“许可证”的服务器。 java, 然后把该网页转往新时代的许可,或者仅仅有该服务器,就会产生新的装载时间,将其与原有时间进行比较。 然后,该信封是逻辑的,然后将该页转至许可证。 jsp.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...