[jdom-interest] Re: Problems with JSP/JDOM
flavio at bs2.com.br
Thu Sep 23 04:29:58 PDT 2004
rforster at melbpc.org.au disse:
> Hi Flavio.
> You wrote:
>> recently converted an app fro terminal-mode to JSP (In teminal mode
>> everything runs ok).
>> Everything works well in JSP until trying to get the returned XML.
>> I couldn't find anything about this...
> I teach exactly this topic here in Australia. There is a collection of
> tutorials at
Thanks lot. But my JSP doesn't involve file writing. It calls another app
that works with sockets. The response XML comes over the socket and can
never be stored as a file. It must be parsed and formatted as HTML using
the socket OutputStream. Sometimes it works, sometimes I get "Premature
end of file exception". No idea about this. I can't identify what's going
wrong since the app behavior seems randomical.
The JSP fragment where I believe the problem resides is:
// at this point, inputDoc is correctly assembled.
// variable declarations supressed. They are OK, believe me ;)
XMLOutputter outputter = new XMLOutputter();
Socket sock = new Socket("localhost",4445);
sock.getInputStream().read(); // This is a dummy byte sent by socket to
say "OK, I finished."
byte socketThing = new byte[sock.getInputStream().available()];
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new ByteArrayInputStream(socketThing));
<font face="Arial, Helvetica, Sans-serif" size="2">
out.println("Empresa de captura: " +
transacao.getChild("empresacaptura").getText() + "<br>");
out.println("Tipo da operação: " +
transacao.getChild("tipooperacao").getText() + "<br>");
More information about the jdom-interest