简体   繁体   English

存储JSP呈现的HTML文件

[英]Storing HTML file rendered by JSP

I need to create a report using Servlet and jsp. 我需要使用Servlet和jsp创建报告。 My problem is this, there is a page which list the previously generated report. 我的问题是,有一个页面列出了先前生成的报告。 One can click on any of this report from list and view that report again. 您可以从列表中单击任何此报告,然后再次查看该报告。 For this I have to keep the static html file Rendered by the jsp on the server. 为此,我必须在服务器上保留由jsp渲染的静态html文件。 How can i obtain this. 我如何获得这个。 I don't want to render the jsp file twice as this is time consuming. 我不想使JSP文件的两倍,因为这是费时。

Thanks in advance. 提前致谢。

Basically, you should write the body of your HTTP response object to a file on your webserver and write some kind of service/servlet to retrieve these files. 基本上,您应该将HTTP响应对象的主体写入Web服务器上的文件,并编写某种服务/ servlet来检索这些文件。 I guess the easiest way to do this, is by writing a ServletFilter that intercepts the responses of your JSPs. 我猜想,最简单的方法是编写一个ServletFilter来拦截您的JSP的响应。

The current Oracle Java EE 6 tutorial is rather brief about Filters, but you can read all about them in the previous version : http://docs.oracle.com/javaee/5/tutorial/doc/bnagb.html 当前的Oracle Java EE 6教程对过滤器非常简短,但是您可以在以前的版本中阅读有关过滤器的所有信息: http : //docs.oracle.com/javaee/5/tutorial/doc/bnagb.html

You could cache the reports by adding a Filter . 您可以通过添加Filter来缓存报告。 The filter can check if an already rendered version is available and return the contents of that file. 筛选器可以检查是否已渲染的版本可用,并返回该文件的内容。 If no file is present it can write the resulting response to the cache. 如果没有文件,它可以将结果响应写入缓存。

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

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