The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Won't Compile Servlet
Discuss Won't Compile Servlet in the Java Help forum on Dev Shed. Won't Compile Servlet Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 2nd, 2002, 09:36 PM
|
|
Junior Member
|
|
Join Date: Jul 2001
Location: Connecticut, US
Posts: 8
Time spent in forums: < 1 sec
Reputation 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
|

April 2nd, 2002, 10:09 PM
|
|
Junior Member
|
|
Join Date: Apr 2002
Location: Modesto, CA US
Posts: 1
Time spent in forums: < 1 sec
Reputation 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.
|

April 2nd, 2002, 10:22 PM
|
|
Member
|
|
Join Date: Mar 2002
Location: India
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Eveything is fine with the pgm....u just have to import javax.servlet.http.*;
Thats were u can find HttpServlet class file....
|

April 2nd, 2002, 10:26 PM
|
|
Junior Member
|
|
Join Date: Jul 2001
Location: Connecticut, US
Posts: 8
Time spent in forums: < 1 sec
Reputation 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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|