I tried what Robert suggested but using JAXP but get the same
SAXParseException - Premature end of file.
If I just use request.getInputStream() and write the bytes to file and
then parse that it's fine. Parsing straight from the request doesn't
seem to work for me though.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new
InputSource(request.getInputStream()));
}
thanks,
Alistair
On 15 Dec 2004, at 09:28, Stanimir Stamenkov wrote:
/Alistair Young/:
Is there any way in Xerces/JAXP to parse an HTTP stream? I have an
XML doc as POST data, received via HTTP. Create an InputStream for
the bytes and pass it to DocumentBuilder.parse(InputStream). It
always throws a premature end of file exception. The only way that
works is to write it to file first, then parse it.
Show some code of your case.
DocumentBuilderFactory builderFactory;
...
(ServletRequest req, ServletResponse resp)
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document doc = builder.parse(req.getInputStream());
Does it work?
While it is not typically the case the ServletRequest.getParameter()
documentation describes it could interfere with the
ServletRequest.getInputStream() when the parameters are served with
the request body (as it is the case with HTTP POST).
--
Stanimir
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xxxxxxxxxxxxxx
For additional commands, e-mail: xerces-j-user-help@xxxxxxxxxxxxxx
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|