This week's giveaways are in the MongoDB and Jobs Discussion forums. We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line! See this thread and this one for details.
Why the SnoopServlet in Tomcat 3.2.1 doesn't compile?
Sam Zheng
Ranch Hand
Joined: Nov 29, 2000
Posts: 61
posted
0
I couldn't figure out why the SnoopServlet.java that comes with Tomcat 3.2.1 doesn't compile. The compiler complains about that the parameter "context", which is a ServletContext, doesn't have a method "getInitParameterNames()", among other things. I have also tried to directly call the SnoopServlet.class that comes together with Tomcat3.2.1, then it gives me an Error 500 message. Would any kind soul please help me out? I am enclosing the SnoopServlet.java as follow: /* $Id: SnoopServlet.java,v 1.3 1999/10/15 21:31:49 duncan Exp $ * */ import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.*; import javax.servlet.http.*; /** * * * @author James Duncan Davidson <duncan@eng.sun.com> * @author Jason Hunter <jch@eng.sun.com> */ public class SnoopServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); response.setContentType("text/plain"); out.println("Snoop Servlet"); out.println(); out.println("Servlet init parameters:"); Enumeration e = getInitParameterNames(); while (e.hasMoreElements()) { String key = (String)e.nextElement(); String value = getInitParameter(key); out.println(" " + key + " = " + value); } out.println(); out.println("Context init parameters:"); ServletContext context = getServletContext(); Enumeration enum = context.getInitParameterNames(); while (enum.hasMoreElements()) { String key = (String)enum.nextElement(); Object value = context.getInitParameter(key); out.println(" " + key + " = " + value); } out.println(); out.println("Context attributes:"); enum = context.getAttributeNames(); while (enum.hasMoreElements()) { String key = (String)enum.nextElement(); Object value = context.getAttribute(key); out.println(" " + key + " = " + value); } out.println();
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12265
1
posted
0
The only possibility I can think of is that you have an old JSDK jar file somewhere on your system that the compiler is finding first. I wasted days on a bizarre error message like this for that reason. Bill