You are missing the servlet.jar file, which contains the neccesary classes for your servlet to compile.
Just make sure your compiler can find the jar file in your classpath. If you have a IDE like netbeans
than you have it easy, just mount the jar file, and you will be able to compile without problems.


kandathil girish wrote:

i am a student and we use Tomcat as our server. I have been trying to run a basic servlet program but have been unsucessful as of yet. My tomact runs perfect, gives me the index page and stuff.

Bu my servelt comiples with following errors

C:\Tomcat 4.1\webapps\ROOT\WEB-INF\Classes\HelloWWW.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
C:\Tomcat 4.1\webapps\ROOT\WEB-INF\Classes\HelloWWW.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\Tomcat 4.1\webapps\ROOT\WEB-INF\Classes\HelloWWW.java:13: cannot resolve symbol
symbol : class HttpServlet location: class HelloWWW
public class HelloWWW extends HttpServlet {
^
C:\Tomcat 4.1\webapps\ROOT\WEB-INF\Classes\HelloWWW.java:14: cannot resolve symbol
symbol : class HttpServletRequest location: class HelloWWW
public void doGet(HttpServletRequest request,
^
C:\Tomcat 4.1\webapps\ROOT\WEB-INF\Classes\HelloWWW.java:15: cannot resolve symbol
symbol : class HttpServletResponse location: class HelloWWW
HttpServletResponse response)
^
C:\Tomcat 4.1\webapps\ROOT\WEB-INF\Classes\HelloWWW.java:16: cannot resolve symbol
symbol : class ServletException location: class HelloWWW
throws ServletException, IOException {
^
6 errors
Tool completed with exit code




the code for the same is as follow:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Simple servlet that generates HTML.
*  <P>
*  Taken from Core Servlets and JavaServer Pages
*  from Prentice Hall and Sun Microsystems Press,
*  http://www.coreservlets.com/.
*  &copy; 2000 Marty Hall; may be freely used or adapted.
*/
public class HelloWWW extends HttpServlet {
 public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   String docType =
     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
     "Transitional//EN\">\n";
   out.println(docType +
               "<HTML>\n" +
               "<HEAD><TITLE>Hello WWW</TITLE></HEAD>\n" +
               "<BODY>\n" +
               "<H1>Hello WWW</H1>\n" +
               "</BODY></HTML>");
 }
}




---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to