Search code examples
javaxmljspsessionjdom

Size of jdom document vs single variables


I planning on reading profile data from a xml file in JSP.

Now i can either read it and store the important information in single session variables or just put the whole section from the xml file in a jdom document and put that into a single session variable.

In your experience, will the data size impact the big or negligible ?


Solution

  • There is a rule of thumb when it comes down to storing XML in memory with DOM. The size of the XML-file * 10. So if you XML-File is 1MB big then you will need 10MB memory to store it.

    But in my experience i would never ever store a DOM document in memory. Once some student tried to do that, but the XML-File was 50MB big, so guess what happens? We ran out of Memory.

    For your case i would create a class which can hold all the relevant information, fill the class by reading the xml.

    Do you really need to store the profile data in the session? Do you really need it all the time? Sometime it is enough to just the an id or a small class.