What is the maximum limit (i.e. size) of data that a HTTPSession variable can hold? What will happen if this exceeds? And most importantly, what is the alternative approach to have the data throughout the session if the size exceeds the maximum size that a HTTPSession variable can hold?
There is no limit, other than the memory of your server. The alternatives are
- to run your server with more memory
- to configure the server to swap sessions to disk (see http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html for Tomcat)
- to avoid putting large data in the session, and to use a cache or a database to store them instead.
来源:https://stackoverflow.com/questions/11699065/httpsession-variable-limit