• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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\SimpleServlet.java:1: 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 servlets.properties file be placed in?
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chitra,
The servlets.properties 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 (charasala@yahoo.com), 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 servlets.properties 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 java.io.*;
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).]
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!