File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet and SAX Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet and SAX Error " Watch "Servlet and SAX Error " New topic
Author

Servlet and SAX Error

dan jensen
Greenhorn

Joined: Apr 17, 2003
Posts: 2
Hello, I am trying to parse xml sent via HTTP within a servlet. I've created a class, Echo, which handles the parsing of the data. I call the Echo class from my servlet, providing it the xml data. I am getting the following error message when I compile:
cannot resolve symbol
symbol : constructor Echo ()
location: class Echo
DefaultHandler handler = new Echo();
Anyone have any idea how I can resolve this error?

Here is my code:
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GreetingServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
String DATA = request.getParameter("DATA");
if(DATA != null){
Echo pXML = new Echo(DATA);
}
}
}
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
public class Echo extends DefaultHandler
{
public Echo(String instring)
{
// Use an instance of ourselves as the SAX event handler
DefaultHandler handler = new Echo();
....
}
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12678
    
    5

Since you have specified a constructor that uses a String, the compiler won't automatically supply a no-args constructor as in your line.
DefaultHandler handler = new Echo();
But it seems to me you don't want to install another Echo - you want to use "this" Echo.
Bill


Java Resources at www.wbrogden.com
dan jensen
Greenhorn

Joined: Apr 17, 2003
Posts: 2
Thank you William. That was very helpful. I am fairly new to Java so excuse some of questions. I was able to compile it successfully.
Dan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet and SAX Error
 
Similar Threads
problems with JAXP
problems with JAXP
Tomcat problem while reading Data from Xml file
Searching using SAX !!
problems with JAXP