Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 20th, 2004, 01:59 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default about XML receive by tomcatand XML parse by java

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.");
        System.out.println("-----------------------");

        // 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);
        }

        System.out.println("-----------------------");

        if(request.getContentLength() > 0)
        {
    try
    {
            java.io.BufferedReader reader = request.getReader();
            XMLReader parser=XMLReaderFactory.createXMLReader(
           "org.apache.xerces.parsers.SAXParser");
            //·ÖÎöÎļþ
            parser.parse(new org.xml.sax.InputSource (reader));
           }
           catch(IOException ioe)
          {
         System.out.println(ioe.getMessage());
           }
           catch(SAXException saxe)
           {
               System.out.println(saxe.getMessage());
            }
              }
System.out.println("____________________________") ;

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



Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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
copy xml to xml (with java script) Umen XML 4 September 14th, 2004 06:51 AM
about XML receive ang XML parse by tomcat taianmhzy Apache Tomcat 0 May 20th, 2004 01:56 AM
not able to receive xml data unniml Classic ASP XML 0 January 30th, 2004 09:00 AM



All times are GMT -4. The time now is 01:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.