• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet package not found

 
shabbir zakir
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Beksy Kurian
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic