aspose file tools*
The moose likes Servlets and the fly likes Compiling the servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

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

Compiling the servlet

Chitra Sundaram

Joined: Oct 24, 2000
Posts: 18
I have downloaded JSDK 2.1 and have written a simple servlet. I am unable to compile this. It gives me a compiler error as follows:
C:\JavaAssg\ cannot resolve symbol
symbol : class HttpServlet
location: class SimpleServlet
public class SimpleServlet extends HttpServlet{

and more
which indicates to me that it is unable to find the class HttpServlet. I already have c:\jsdk2.1\server.jar, c:\jsdk2.1\servlet.jar and c:\jsdk2.1\src in my classpath.
Can somebody please help me??

And also... which directory should the file be placed in?
Prasad Charasala
Ranch Hand

Joined: Nov 02, 2000
Posts: 67
Hi Chitra,
The file must be under yourJSDKfolder/webpages/web-inf.
If you have unzipped the downloaded zip file it will place all the files appropriately.
Send me your servlet code (, I will fix it and send it back to you.

Prasad Charasala
Ranch Hand

Joined: Nov 02, 2000
Posts: 67
Hi Chitra,
The code is perfectly correct except it is missing import statements. I ran it on my machine it perfectly works. The code should have the three import statements. Follow the following steps to run it.
1. Make sure your classpath has c:\Jsdk2.1\server.jar;c:\Jsdk2.1\servlet.jar.
2. Put the source code in c:\Jsdk2.1\webpages\web-inf\servlets folder.
3. Compile it and make sure your generated class file is in the same servlets folder.
4. You have a file under c:\Jsdk2.1\webpages\web-inf. make sure to add the following line
5. Save the properties file. go to c:\Jsdk2.1 folder and start the server.
6. Now try this url from your browser
http://localhost:8080/servlet/simple or http://localhost:8080/servlet/SimpleServlet
It must work. Please note there is no 's' in the url. It is not 'servlets', only 'servlet'.
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleServlet extends HttpServlet{
public void doGet( HttpServletRequest request,
throws ServletException, IOException
PrintWriter out;
String title="Simple Servlet Output";
out.println("<P>This is output from SimpleServlet.");

[This message has been edited by Prasad Charasala (edited November 07, 2000).]
I agree. Here's the link:
subject: Compiling the servlet
Similar Threads
JavaServlet-CLASSPATH problem
Jsdk2.1 and Jws 2.0 Compiling & cp problem
Compiling the servlet, please help
Need help urgently: problems compiling servlets
Error: Package javax.servlet not found