#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Connecticut, US
    Posts
    8
    Rep Power
    0

    Won't Compile Servlet


    I've have tried for days to figure this out, and I know its something stupid, but when I try to compile:

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.*;

    public class HelloWorld extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = response.getWriter();

    out.println("<html>");
    out.println("<head><title>Hello World</title></head>");
    out.println("<body>");
    out.println("<big>Hello World!</big>");
    out.println("</body></html>");
    }
    }

    I get:
    C:\JSrc\HelloWorld.java:5: cannot resolve symbol
    symbol : class HttpServlet
    location: class HelloWorld
    public class HelloWorld extends HttpServlet {

    I have this setup:
    SET PATH=C;\WINDOWS;C:\WINDOWS\COMMAND;C:\jdk1.3.1\bin
    set JAVA_HOME=C:\jdk1.3.1
    set CLASSPATH=C:\jdk1.3.1\lib;C:\Tomcat4\common\lib\servlet.jar
    set CATALINA_HOME=c:\Tomcat4

    I get the Servlet.Jar in my path.
    C:\WINDOWS>echo %classpath%
    C:\jdk1.3.1\lib;C:\Tomcat4\common\lib\servlet.jar

    Can someone please kick my head in the right direction?

    Thanks in advance,

    Brad
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Location
    Modesto, CA US
    Posts
    1
    Rep Power
    0
    This isn't the proper way, but try finding where j2ee.jar is on your computer and put it in the classpath. If you don't have it just grab the J2EE SDK off the Java site.
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    India
    Posts
    7
    Rep Power
    0
    Eveything is fine with the pgm....u just have to import javax.servlet.http.*;
    Thats were u can find HttpServlet class file....
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    Connecticut, US
    Posts
    8
    Rep Power
    0

    Never mind (duh)


    I went ahead and kicked myself in the head.

    Line3 had just "servlet.*;" instead of "servlet.http.*;"

    on " res.setContentType("text/html"); " the book just had res, but to make it work I had to add the whole word "response".

    I also just put the servlet.jar the jre ext folder, which I'm not sure that really mattered though because I had it in my path supposedly.

    Three days to figure that out, believe it or not. Live and learn

    Brad

IMN logo majestic logo threadwatch logo seochat tools logo