aspose file tools*
The moose likes Servlets and the fly likes Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets" Watch "Servlets" New topic
Author

Servlets

Ashu Gupta
Greenhorn

Joined: Feb 15, 2001
Posts: 2
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{
Ajan Balakrishnan
Ranch Hand

Joined: Jan 04, 2001
Posts: 71
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

Joined: Feb 15, 2001
Posts: 2
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.
Tualha Khan
Ranch Hand

Joined: Nov 22, 2000
Posts: 287
i typed the following line in my autoexec.bat file and the servlet compiled:
set classpath=c:\jsdk\lib\jsdk.jar;
Bye,
Tualha Khan


SCJP2, BEA WLS 6.0, DB2 UDB 7.1
Ajan Balakrishnan
Ranch Hand

Joined: Jan 04, 2001
Posts: 71
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
 
Consider Paul's rocket mass heater.
 
subject: Servlets