Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
I post a text XML with Microsoft.XMLHTTP to servlet

I post a text XML with Microsoft.XMLHTTP to servlet

2003-10-14       - By Blackmore, John

 Back
Reply:     1     2     3     4     5  

Hi,
I have the same problem. Can you elaborate on the "...", ie how to extract
the XML string from the request? I've tried a few different methods without
success. I'm running Tomcat 4.1.24-LE-jdk14 on Solaris. I have a servlet
that clients post XML to. One client uses XMLHTTP object to do the post, and
that's the one that's causing problems. All other clients are fine. I'd like
to post the two approaches I've tried to resolve this, then maybe someone
can tell me what I'm doing wrong or how to work around this?

First, the simple, obvious approach - simply build a document from the input
stream:

  DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
  Document document = builder.parse(req.getInputStream());

When I try this, I get "org.xml.sax.SAXParseException Source code of org.xml.sax.SAXParseException: Content is not
allowed in prolog".

Second, I tried to forcibly retrieve characters from the input stream, one
by one.  

  String xmlDocString = getXMLString((InputStream)
req.getInputStream());
  Document document = builder.parse(new
StringBufferInputStream(xmlDocString));

Note: the getXMLString() function is not very interesting... simply has a
loop as follows:

  while( (c=xmlInputStream.read()) > 0 )

When I try this, I get the same error, however I don't get an empty string -
xmlDocString has what looks like a URL encoded and truncated version of the
original string.

I would really appreciate any insight as to why this happens, even if a
solution is not forthcoming. Thanks!

John Blackmore

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
Howdy,
You need to read the whole request into a String.  Then, since you want
a DOM document, use a DOM document builder to get it, e.g.
String xmlInput = ...
Reader reader = new Stringeader(xmlInput);
InputSource inputSource = new InputSource(reader);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(inputSource)

(The above are mixed imports from java.io, javax.xml.parsers,
org.w3c.dom).

Yoav Shapira
Millennium ChemInformatics


>-- --Original Message-- --
>From: Jose Alanya [mailto:[EMAIL PROTECTED]
>Sent: Thursday, October 09, 2003 6:21 PM
>To: [EMAIL PROTECTED]
>Subject: I post a text XML with Microsoft.XMLHTTP to servlet
>
>Hi,
>
>I post a text XML with  Microsoft.XMLHTTP to servlet,
>As I can recover the value of object request from of servlet
>This can :
>something like  :  Document oDocument = xml.paser(objrequest)
>
>Not getparameter, not getquerystring
>
>Please  help me!
>Thanks,
>
>best regards,
>Jose Alanya
>From, Lima Peru





**************************************************************************
This e-mail and any files transmitted with it may contain privileged or
confidential information. It is solely for use by the individual for whom
it is intended, even if addressed incorrectly. If you received this e-mail
in error, please notify the sender; do not disclose, copy, distribute, or
take any action in reliance on the contents of this information; and delete
it from your system. Any other use of this e-mail is prohibited. Thank you
for your compliance.




-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.