使用jsp:include的JSP性能 [英] JSP Performance using jsp:include

查看:155
本文介绍了使用jsp:include的JSP性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始将一个大型JSP文件分解为一些较小的JSP页面,以便我可以在网站的其他区域重用它。

I am beginning to break apart a large JSP file into a some smaller JSP pages so I can reuse this across other areas of the site.

我可以采用离开的方法作为一个大型的Monolithic JSP文件,它接受参数并相应地调整它的行为。我可以采取的另一种方法是将它分开,以便通过jsp:include调用它。

I can take the approach of leaving as a large Monolithic JSP file that takes params and adjusts it's behavior accordingly. The other approach I can take is breaking it apart so that it's called via jsp:include.

创建从服务器内调度的其他请求调用时,性能问题是什么?将它保存为一个jsp页面是否更好的性能?

What is the performance concern in creating additional request calls that are dispatched from within the server? Is it better performance wise to keep it as one jsp page?

推荐答案

jsp:include 是一个运行时指令,与<%@ include ...%> 指令不同,它恰好是编译时指令(实际上是转换时间) 。编译时include指令相对无害,因为JSP通常是为生产预编译的,或者是在为应用程序的每个部署编译的最坏情况下。因此,最好对静态文件使用编译时指令,因为文件不会在运行时更改。

The jsp:include is a runtime directive unlike the <%@ include ... %> directive which happens to be a compile time directive (translation time, actually). A compile time include directive is relatively harmless since JSPs are usually precompiled for production, or in the worst case compiled for every deployment of the application. For this reason, it is preferable to use the compile time directive for static files, since the files are not bound to change at runtime.

运行时include指令另一方面head,如果被误用,可能会导致一些性能损失,特别是对于包含的静态文件。这主要是因为JSP容器必须获取静态文件的内容并将它们包含在响应中。因此,保留运行时指令的用法,用于真正有用的场景,其中另一个servlet或jsp的响应将包含在响应中,而不仅仅是为了使代码看起来很好。

The runtime include directive on the other head, if misused, can result in some performance hit, especially for static files being included. This is primarily because the JSP container would have to then fetch the contents of the static file and include them in the response. Hence, reserve the usage of the runtime directive for the really useful scenarios where another servlet or jsp's response is to be included in the response, and not merely to make the code look good.

这篇关于使用jsp:include的JSP性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆