aspose file tools*
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 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet package not found" Watch "servlet package not found" New topic
Author

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.io.*;
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
{
response.setContentType("text/plain");
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
Hello.
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, www.gsi3d.org.uk
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
/jrun/../lib/servlet.jar
or tomcat/..lib/servlet.jar
This should solve your problem
Beksy
shabbir zakir
Ranch Hand

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

Joined: Jun 25, 2001
Posts: 15665
    
  15

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.
CLASSPATH=$CLASSPATH:$TOMCAT_HOME/lib/servlet.jar
export CLASSPATH
works for Linux. For Win32 it's
SET CLASSPATH=%CLASSPATH%;%TOMCAT_HOME%\lib\servlet.jar


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet package not found
 
Similar Threads
directive tag
parameter from MIDlet cannot be displayed at servlet
HttpServletRequest.getHeaders(aString)
Client browser type and platform detection thru Servlets
why?help me! : the import javax.servlet is never used