• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet and SAX Error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
....
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
dan jensen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic