Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 20th, 2004, 01:56 AM
Registered User
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default about XML receive ang XML parse by tomcat

I want to parser XML (sended by Apache SOAP and tomcat),tomcat Receive by " C:\Program Files\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes\HTTPReceive",but i don't how write completely? please give directions!thanks !

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.FileInputStream;
import java.util.Properties;
import org.xml.sax.Attributes;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
public class HTTPReceive extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
        System.out.println("Received GET request");
        response.setStatus(HttpServletResponse.SC_BAD_REQU EST);

    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
        System.out.println("____________________________") ;
        System.out.println("Received request.");

        // Traverse the HTTP headers and show them on the screen
        for(Enumeration enum = request.getHeaderNames();
          enum.hasMoreElements(); ){
            String header = (String)enum.nextElement();
            String value = request.getHeader(header);

            System.out.println(" " + header + " = " + value);


        if(request.getContentLength() > 0)
            java.io.BufferedReader reader = request.getReader();
            XMLReader parser=XMLReaderFactory.createXMLReader(
            parser.parse(new org.xml.sax.InputSource (reader));
           catch(IOException ioe)
           catch(SAXException saxe)
System.out.println("____________________________") ;

        response.setContentType("text/xml"); // Need this to prevent Apache SOAP from gacking

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send and Receive XML content through browser kj875 ASP.NET 2.0 Basics 0 July 27th, 2007 12:10 AM
how to send and receive xml data from webService Divesh4u Classic ASP XML 0 May 22nd, 2006 01:10 PM
Parse XML response atulb XML 1 October 30th, 2005 07:05 AM
about XML receive by tomcatand XML parse by java taianmhzy Servlets 0 May 20th, 2004 01:59 AM
not able to receive xml data unniml Classic ASP XML 0 January 30th, 2004 09:00 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.