Why are Java entity classes implementing serialization

Source: Internet
Author: User
public class User implements Serializable {}

When a client accesses a resource that can turn on a session, the Web server creates a HttpSession object corresponding to that client, and each HttpSession object consumes some memory space. If there is a lot of users accessing the site at a certain time, the Web server memory will accumulate a large number of HttpSession objects, consuming a lot of server memory, even if the user has left or closed the browser, the Web server still retains its corresponding HttpSession object, The Web server memory resource has been occupied until they time out.

The Web server typically transfers HttpSession objects that are temporarily inactive but not timed out to the file system or database, and the server uses them to load them from the file system or database into memory, a technique called session persistence.

Saving the HttpSession object to a file system or database requires that each Property object in the HttpSession object be serialized to be saved to the file system or database, and the HttpSession object is loaded from the file system or database, such as memory, Each Property object in the HttpSession object needs to be restored in a deserialized manner. Therefore, each Property object stored in the HttpSession object must implement the Serializable interface

Why are Java entity classes implementing serialization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.