[英]Remove files after session expiry in java web application
I have a java web application that generates and displays graphical pictures based upon some user parameters. 我有一个Java Web应用程序,可以根据一些用户参数生成并显示图形图片。
I used to store the graphics in the Session map, but that is generally not a good idea (you want to keep the session data as small as possible). 我曾经将图形存储在Session映射中,但这通常不是一个好主意(您希望保持Session数据尽可能小)。
So instead, I only want to generate a file on the server and refer to it via an URL that I will store in the session map. 因此,我只想在服务器上生成一个文件,并通过将存储在会话映射中的URL引用它。
The question is: How can I remove the generated file after the session expires? 问题是:会话期满后如何删除生成的文件? I do not want to be stuck with a lot of graphics and I do not like the idea of just cleaning the folder with generated graphics at midnight as a user may be using my website at that time.
我不想被很多图形卡住,也不喜欢在午夜用生成的图形清理文件夹的想法,因为那时用户可能正在使用我的网站。
It could also be that there are other means to accomplish what I want. 也可能有其他方法可以实现我想要的功能。 I'm interested what's the best practice for this kind of retrieval from the server.
我对从服务器进行这种检索的最佳实践是什么感兴趣。
创建一个会话侦听器HttpSessionListener并删除其中的文件
public void sessionDestroyed(HttpSessionEvent se);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.