This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes new to Tomcat and JSP&Java Servlet,pls help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "new to Tomcat and JSP&Java Servlet,pls help" Watch "new to Tomcat and JSP&Java Servlet,pls help" New topic
Author

new to Tomcat and JSP&Java Servlet,pls help

Kathy Wang
Greenhorn

Joined: Sep 06, 2001
Posts: 28
Hi,
I have downloaded Tomcat4 and have got it run. But when I tried to compile Java servlet file, it gave errors like
HelloWorld.java:4: package javax.servlet does not exist
import javax.servlet.*;
my jdk is in c:\jdk1.3.1, tomcat is in c:\tomcat4, JAVA_HOME=c:\jdk1.3.1 and TOMCAT_HOME=c:\tomcat4. And I already setup CLASSPATH=.\;C:\JDK1.3.1\LIB\TOOLS.JAR\;
I searched this site's related threads, they talked about setting up classpath also to CLASSPATH=c:/tomcat/lib/servlet.jar
,But I can not find the servlet.jar file in the correspond directory c:/tomcat4/lib/, What should I do? Can you please give me some advice?
Any reply is highly appreciated!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yup, you need those classes, but they can be found in either servlet.jar or j2ee.jar
Servlet.jar should already exist in TOMCAT_HOME/common/lib and you can add this to your classpath or drop servlet.jar in your JAVA_HOME/lib directory
Dave.
Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
Kathy:
I had this problem too. You know what! I pulled half of my hair out to solve this problem.
Please follow as bellow you will have less pain.
Copy servlet.jar file from tomcat4\common\lib\[copy file servlet.jar] and paste it at jdk1.3\jre\lib\ext\[paste at here servlet.jar file].
It will solve your package javax.servlet does not exist
import javax.servlet.*;
By the way, Have you try tomcat sample servlet examples? Are they running? If they are you are all set, now rock and roll. Otherwise you got to set calsspath for CATALINA_HOME = tomcat4.0 . My best advise for all these go through tomcat docs. It takes time but comes out.
I wish there were book like "Tomcat Installation for Dummies", I would have been first guy to reserve first copy of their first publication. It was lot pain. I do not want to see other people marching this route. If you need more information keep posting.
GOOD LUCK. BK
Hi,
HelloWorld.java:4: package javax.servlet does not exist
import javax.servlet.*;

Kathy Wang
Greenhorn

Joined: Sep 06, 2001
Posts: 28
Thanks Dave and BK!
BK, I did run the sample servlet, they did not run either. You mean I need to add: set classpath=c:\tomcat4; ?
If there were a book "Tomcat Installation for Dummies", I will do the same thing as you. But right now, I will follow your advice and keep reading the tomcatdocs. Thanks again.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Kathy, try copying servlet.jar to your jdk1.3.1/jre/lib/ext directory

Bosun


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
imb4u2cu
Greenhorn

Joined: Jul 27, 2001
Posts: 7
SET JAVA_HOME=C:\JDK1.3
SET CATALINA_HOME=C:\TOMCAT4.0
SET PATH=%JAVA_HOME%\BIN;%CATALINA_HOME%\BIN;
SET CLASSPATH=%CLASSPATH%;C:\mydir\servlet.jar;
Startup.bat
Now check as:
localhost:8080 Tomcat's index page must be there..
Write me back if any problem.

------------------
I am before you to see you!!!


I am before you to see you!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new to Tomcat and JSP&Java Servlet,pls help
 
Similar Threads
import javax.servlet.*;
Running servlets
Simple CLASSPATH problem for compilation of servlets in JWS2.0
Help please!!! Environment var.......
using ant to achive files