views:

41

answers:

2

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 parallel. Is there any way to do it in JSP?

+1  A: 

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.

BalusC
A: 

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>
Michael Angstadt