Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Compiling the servlet  RSS feed

Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!