File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet and SAX Error " Watch "Servlet and SAX Error " New topic

Servlet and SAX Error

dan jensen

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.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 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

Joined: Mar 22, 2000
Posts: 13037

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.
dan jensen

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.
I agree. Here's the link:
subject: Servlet and SAX Error
It's not a secret anymore!