A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
Unable to compile servlet
chailin fong
Greenhorn
Joined: Oct 15, 2007
Posts: 10
posted
Nov 12, 2007 21:36:00
0
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: 56528
14
I like...
posted
Nov 12, 2007 21:42:00
0
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 ]
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
I agree. Here's the link:
http://aspose.com/file-tools
subject: Unable to compile servlet
Similar Threads
Servelts Error from Head First Servlets & JSP
javax.servlet.http.* missing?
problem working on Servlets..plz help..
compiling Servlet Example in HF Servlets & JSP
compile errors
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter