Does this mean any objects can also be transferred this way?
I will have to make my object into a XML file and upload it to the servlet?
Tim Moores wrote:No files are involved. The XML is created in memory, and then streamed directly to the servlet URL.
Basically, just be aware that HTTP is a text protocol. Anything passed to and fro via HTTP must be text.
Tim Moores wrote:Something like this:
Then the XML can be retrieved as request parameter "stringToReverse" (and decoded by the XMLDecoderclass). The details may be wrong, but that's the general idea. Generally, you shouldn't call String.getBytes() without specifying an encoding, but since it's all ASCII (in line 6), it's OK in this case.
Bear Bibeault wrote:Yes, but is not the content encoded to text for transfer? (Or am I thinking of the email protocol?)
Tim Moores wrote:OK, one more hint: The way to get a byte from a String is the String's getBytes() method. And I already mentioned the ByteArrayInputStream class.
Paul Clapham wrote:It's preferable to parse from a StringReader, rather than converting the String to bytes using an unknown encoding and then passing those bytes to the parser to be converted back to chars using a potentially different encoding.
As for your most recent exception, you do need to pass a well-formed XML document to the parser. Looks to me like you passed an empty string.
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earthhttps://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter