[jdom-interest] Failing early on maxLength violations
jdotmc at gmail.com
Tue Dec 13 16:38:19 PST 2005
I am currently developing a web service that accepts images, among
other things. I am debating having the images submitted in the XML
using base64Binary typed elements. Using a maxLength restriction on
these elements, I plan on limiting images to around 512 KB, mainly
because I am concerned about both bandwidth and memory (parsing and
One question I still have is, what happens if a user uploads a 5 MB
photo? I would love for the 512 KB maxLength to protect me from this,
but some initial tests indicate that the SAXBuilder won't throw an
exception until the end tag for the element it's parsing is reached.
At that point, I've already sucked the entire 5 MB worth of data into
memory, though I am saved the decoding costs.
Is there any way to have the SAXBuilder throw the exception as soon as
the maxLength is exceeded?
Thanks for any insight,
More information about the jdom-interest