简体   繁体   English

是否可以保存服务器上servlet返回的网页以再次访问?

[英]is it possible to save the web page that is returned by a servlet on the server to access again?

Say I have a servlet that processes form data and returns a web page. 假设我有一个处理表单数据并返回网页的servlet。 Is it possible to store the web page that is returned on the server so that it can be accessed again without filling out the form? 是否可以存储在服务器上返回的网页,以便无需填写表格即可再次访问它?

I think its possible. 我认为有可能。 But mostly it will be possible if the form submitted generated a unique page with unique URL. 但是大多数情况下,如果提交的表单生成具有唯一URL的唯一页面,这将是可能的。

Like let say when u submit a form and if it created a URL like 假设您提交表单时是否创建了网址,例如

' http://example.com/result1.html ' ' http://example.com/result1.html '

then we can use the Expiration filter to set the Expiration HTTP header and make it cacheable. 那么我们可以使用Expiration过滤器来设置Expiration HTTP标头并使其可缓存。

But one change is that the caching has to be done by a separate caching server and i hope tomcat cannot do it by itself. 但是一个变化是,缓存必须由单独的缓存服务器完成,我希望tomcat不能自己完成。

One possible way is - 一种可能的方法是-

You save the form object along with a unique url generated as key pair value. 您保存表单对象以及作为键对值生成的唯一URL。 so key will be your unique url and value will be the form object which you have to display on the page and you got what you want. 因此key将是您唯一的url,value将是您必须在页面上显示并获得所需内容的form对象。

Few more hint - 更多提示-

  1. To generate unique url suppose your result page is ' http://example.com/result.html ' you can add a auto increment number like ' http://example.com/result1.html ' managed programatically. 要生成唯一的url,假设您的结果页为“ http://example.com/result.html ”,则可以添加以编程方式管理的“ http://example.com/result1.html ”这样的自动递增编号。 or you can also thing about UUID class available in java. 或者,您也可以在Java中使用UUID类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM