|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
Eveything is fine with the pgm....u just have to import javax.servlet.http.*;
Thats were u can find HttpServlet class file.... |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Won't Compile Servlet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|