开发者

Large data passing to JSP page from Struts 1.3 Action subclass

I want to send a large amount of data to a JSP page from an Action subclass.

My questions:

  1. What is the most effective way to send data from an Action subclass to a JSP page in Struts?

  2. What problems can I face doing so?开发者_C百科

  3. What if I put two big ArrayLists on a request using request.setAttribute() and read that request on the JSP page ?


When you are returning large amount of data from action to JSP in Struts 1/2, you are not sending it over the wire. It is not redirecting, but forwarding. This means that the data returned from the action will be available by reference in the JSP. No copying and network transport is involved. Of course if you render a huge content using JSP and the model you've provided, it will take a lot of time to send it back to the client. But communication between the action and the view (JSP) per se happens in-memory during the processing of one request. Nothing to be worried about.

I think this applies to every framework that returns model from the controller to the view - nothing is copied, just reference passing. Also using request.setAttribute does not copy anything, no cloning is involved.

Warning: this does not apply to session attributes, that are persistent across requests, might be serialized and replicated, etc. But request attributes are fine with big objects, as long as you really need them (?)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜