开发者

JSP parallel include

One thing I like about JSP is include mechanism. In JSP I can simply write:

<jsp:include page='/widget/foo-widget?param=value' />

It works very well when I have some sort of widget and I want incude it on some other page.

The other day I think, It would be nice if include doesn't block thread control, so if I have several includes, they could be processed in para开发者_StackOverflowllel. Is there any way to do it in JSP?


No, there isn't and it is also not worth the effort. HTML response is to be streamed sequentially anyway.

If you're actually doing expensive business stuff to preprocess one and other, then you should already not be using JSP for that, but a Servlet where you've the freedom to spawn threads. This still ought to be done carefully, you don't want to leak threads or to have deadlocks. The java.util.concurrent API may be helpful in this.


You should use the <jsp:param> standard action when putting parameters in a <jsp:include>. This is good because it properly encodes the parameter for inclusion in a URL.

<jsp:include page="/widget/foo-widget">
  <jsp:param name="param" value="value" />
</jsp:include>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜