Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to compile servlet

 
chailin fong
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need help to compile the servlet code from HFJS

Thanks.


===================================================


I try to compile the servlet code from HFJS

This is my file structure: C:\project1
classes
src
etc

I placed Ch1Servlet in C:\project\src;




I used Tomcat 5.028 and installed in c:\program files\tomcat 5.0

The enivornment variables I set up as

classpath .;c:\j2sdk1.4.2_16\lib\tools.jar;c:\j2sdk1.4.2_16\bin;%CATALINA_HOME%\common\lib\jsp-api.jar;%CLASSPATH%

path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\j2sdk1.4.2_16\bin;d:\

JAVA_HOME C:\j2sdk1.4.2_16
CATALINE_HOME C:\program files\tomcat 5.0



I compile the servlet from command(DOS) prompt:

C:\>javac -classpath /project1/classes/tomcat/common/lib/servlet-api.jar
-d classes src/Ch1Servlet.java



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

public class Ch1Servlet extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("<html>" + "<body>" + "<h1 align=center>HF\'s Chapter1 Servlet</h1>"
+ "<br>" + today + "</body>" + "</html>");

}
}


I got 5 errors as
"package javax.servlet does not exist"
"package javax.servlet.http does not exist"
"HttpServletRequest, cannot resolve system", etc




What went wrong???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to check the Servlets FAQ before posting questions to see if your issue has already been addressed.
[ November 12, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic