aspose file tools*
The moose likes Beginning Java and the fly likes Unable to compile servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unable to compile servlet" Watch "Unable to compile servlet" New topic
Author

Unable to compile servlet

chailin fong
Greenhorn

Joined: Oct 15, 2007
Posts: 10
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

Joined: Jan 10, 2002
Posts: 60077
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to compile servlet
 
Similar Threads
problem working on Servlets..plz help..
compiling Servlet Example in HF Servlets & JSP
compile errors
Servelts Error from Head First Servlets & JSP
javax.servlet.http.* missing?