p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Java > Java Open Source > Apache Tomcat
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 20th, 2004, 02:56 AM
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: , , .
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.");
        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
    }


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 01:10 AM
how to send and receive xml data from webService Divesh4u Classic ASP XML 0 May 22nd, 2006 02: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 02:59 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 11:34 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc