简体   繁体   中英

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?

  3. What if I put two big ArrayList s 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 (?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM