• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlets

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've just started working on servlets and when I am trying to compile the code, I get some errors. I'm mentioning the eroors and the code below for your refernce, though I have st the path to
path=c:\jdk1.2.2;c:\jdk1.2.2\bin;c:\jdk1.2.2\lib;c:\jsdk2.0;c:\jsdk2.0\bin;c:\jsdk2.0\lib;c:\jsdk2.0\lib\src.jar;c:\jsdk2.0\src\javax\servlet;c:\jsdk2.0\src\javax\servlet\http
I have also reinstalled the jsdk2.0 on my machine. I'm not able to solve the problem
CODE:
import java.io.*;
import java.util.*;
import javax.servlet.*;
public class postparam extends GenericServlet{
public void service(ServletResponse response, ServletRequest request)
throws ServletException, IOException{
PrintWriter pw = response.getWriter();
Renumeration e = request.getParameterNames();
while(e.hasMoreElements()){
String pname = (String)e.getnextElement();
pw.print(pname + " = ");
String pvalue = (String)e.getnextElement(pname);
pw.print(pvalue);
}
pw.close();
}


}
ERRORS ON COMPILING
1.Package javax.servlet not found in import
import javax.servlet.*;
2.Superclass GenericServlet of class postparam not found.
public class postparam extends GenericServlet{
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look for servlet.jar file under the "lib" directory of your jsdk folder and add that in your classpath. Remember give the fullpath
For example , CLASSPATH=c:\jsdk2.0\lib\servlet.jar
You should be fine now
Ajan
[This message has been edited by Ajan Balakrishnan (edited February 16, 2001).]
 
Ashu Gupta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for the reply friend.
As per your advice I made the necessary changes in the class path but the problem is still there. I'm still getting the same errors evrytime I try to compile. Its not with one file, every file that I try to compile,I get the same set of errors.
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i typed the following line in my autoexec.bat file and the servlet compiled:
set classpath=c:\jsdk\lib\jsdk.jar;
Bye,
Tualha Khan
 
Ajan Balakrishnan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Tualha is saying may be right. I never used jsdk myself,sorry for the wrong info, but most of the other servlet engines i worked with from jswdk to tomcat the servlet api's are packaged inside servlet.jar. To cut short the jar file that should be in the classpath should contain the servlet api's. To confirm this, open up the jar file using any pkzip/pkunzip utility and see if it contains all the interested packages(javax.servlet.*, javax.servlet.http.*)

Ajan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic