File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets" Watch "Servlets" New topic
Author

Servlets

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am using JSDK2.1. What classpath shall I set to compile my servlet programs.
Please help me in this regard.
------------------
Susa
sai
Greenhorn

Joined: Mar 01, 2000
Posts: 23
Originally posted by Soudarsanan:
[B]I am using JSDK2.1. What classpath shall I set to compile my servlet programs.
i hope that u hava path for jdk1.2.2
set path = %path%;c:\jsdk2.1\src;
set classpath = %classpath%;c:\jsdk2.1\src;c:\javawebserver2.0\lib;
sai
Greenhorn

Joined: Mar 01, 2000
Posts: 23
Originally posted by Soudarsanan:
[B]I am using JSDK2.1. What classpath shall I set to compile my servlet programs.
i hope that u hava path for jdk1.2.2
set path = %path%;c:\jsdk2.1\src;
set classpath = %classpath%;c:\jsdk2.1\src;c:\javawebserver2.0\lib;
if any problem mail me gksai10@yahoo.com
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I am unable to compile my program even after adding those classpaths. The following is the code
import java.io.*;
import javax.servlet.*;
public class FirstSer extends GenericServlet{
public void init(javax.servlet.ServletConfig sc) throws ServletException{
super.init(sc);
}
public void service(ServletRequest req, ServletResponse res){
try {
PrintWriter pw = res.getWriter();
res.setContentType("text/HTML");
pw.println("hello this is my first servlet ...");
pw.flush();
}
catch(Exception e){
}
}
public void destroy(){
super.destroy();
}
}
i get the following error when i compile
FirstSer.java:2: Package javax.servlet not found in import.
import javax.servlet.*;
^
FirstSer.java:4: Superclass GenericServlet of class FirstSer not found.
public class FirstSer extends GenericServlet{
^
2 errors
Please help me

------------------
Susa
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Try using :
extends HttpServlet

in doGet/ doPost use parameters :
HttpServletRequest request, HttpServletResponse response

and import :

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
 
 
subject: Servlets