[jdom-interest] Re: Problems with JSP/JDOM

tballen at COPART.COM tballen at COPART.COM
Thu Sep 23 06:58:14 PDT 2004


I have seen the premature end of file message when the content-type of the 
HTTP request was not set properly.  I always set the content-type to 
"application/xml" or "text/xml" and that always gets rid of that error message.

I hope that helps.
Todd


At 08:29 AM 9/23/2004 -0300, Flávio Marim wrote:
>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);
>outputter.output(inputDoc,sock.getOutputStream());
>sock.getInputStream().read(); // This is a dummy byte sent by socket to
>say "OK, I finished."
>Thread.currentThread().sleep(1000);
>byte[] socketThing = new byte[sock.getInputStream().available()];
>sock.getInputStream().read(socketThing);
>SAXBuilder builder = new SAXBuilder();
>
>Document doc = builder.build(new ByteArrayInputStream(socketThing));
>
>%>
><% out.println("
>
>Answer
>
>
>
>"); out.println("Empresa de captura: " + 
>transacao.getChild("empresacaptura").getText() + "
>"); out.println("Tipo da operação: " + 
>transacao.getChild("tipooperacao").getText() + "
>"); } sock.close(); %> -- Flávio Marim 
>_______________________________________________ To control your 
>jdom-interest membership: 
>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com






More information about the jdom-interest mailing list