• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

servlet package not found

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
}
}
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 25830
184
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic