File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes servlet package not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet package not found" Watch "servlet package not found" New topic

servlet package not found

shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
this code is giving me error that javax.servlet.*,javax.servlet.http.* not found. I have included the servlet.jar file in the include folder of jdk1.2
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Extractor extends HttpServlet
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
ServletOutputStream out = response.getOutputStream();
Enumeration eParamNames = request.getParametersNames();
while (eParammames.hasMoreElememts()) {
String name =(String)eParamNames.nextElement();
String value=request.getParameter(name);
out.println(name + "=" + value);
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
Try placing servlet.jar in the "lib" directory, then, in your classpath, explicitly point to "servlet.jar" and not the directory. That should get you rolling.
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
I have a similar problem as above and I'm really struggling to get any servlet to compile. I have servlet.jar under jdk1.3\lib, and the path under win 2000 is pointing right at it but still I get errors like:
package javax.servlet does not exist
import javax.servlet.*;
when I attempt to compile using jdk1.3. This is really frustrating. My servlet book skims over set-up pretty badly. I'm not trying to actually run anything on the server, just trying to get it to compile, but I persistently get these class not found errors. Does anyone know of a really good, clear, easy to follow set-up tutorial I could follow to check I'm not doing something stupid?
many thanks, Ben.

SCJP 1.4,
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
what servlet engine are you using...jrun,tomcat?
The servlet.jar is in the lib directory under jrun(2.3.3) and in the lib/ext directory for jrun 3.1 and i believe that it is in the lib directory of tomcat too.
So in your classpath, you should add
or tomcat/..lib/servlet.jar
This should solve your problem
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
thanks for the reply.i have included the bin in my tomcat folder.i have tried everey possible solutions but still it is not is becoming more and more frustrating for me. pls help me .thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

With the exception of the core libraries, JARs have to be explicitly included - dropping them in directories is insufficient. Tomcat may make that seem untrue, since one of the first things the startup script does is run directories important to it and add the jars it finds to its classpath, but that won't help you compile servlets.
works for Linux. For Win32 it's

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: servlet package not found
It's not a secret anymore!