I want to send a large amount of data to a JSP page from an Action subclass.
My questions:
What is the most effective way to send data from an Action subclass to a JSP page in Struts?
What problems can I face doing so?开发者_C百科
What if I put two big
ArrayList
s on a request usingrequest.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 (?)
精彩评论