Results 1 to 2 of 2
  1. #1
    warriorKnight is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Default cant compile servlets

    i am currently using java SE 6 and i am not able to compile programs using servlets

    i am trying to compile program

    Java Code:
    import java.io.*; 
    import javax.servlet.*; 
    public class HelloServlet extends GenericServlet { 
      public void service(ServletRequest request,  
        ServletResponse response)  
      throws ServletException, IOException { 
        response.setContentType("text/html"); 
        PrintWriter pw = response.getWriter(); 
        pw.println("<B>Hello!"); 
        pw.close(); 
      } 
    }

    but it is giving following errors

    Java Code:
    HelloServlet.java:2: package javax.servlet does not exist
    import javax.servlet.*; 
    ^
    HelloServlet.java:4: cannot find symbol
    symbol: class GenericServlet
    public class HelloServlet extends GenericServlet { 
                                      ^
    HelloServlet.java:6: cannot find symbol
    symbol  : class ServletRequest
    location: class HelloServlet
      public void service(ServletRequest request,  
                          ^
    HelloServlet.java:7: cannot find symbol
    symbol  : class ServletResponse
    location: class HelloServlet
        ServletResponse response)  
        ^
    HelloServlet.java:8: cannot find symbol
    symbol  : class ServletException
    location: class HelloServlet
      throws ServletException, IOException { 
             ^
    5 errors
    please help

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    364
    Rep Power
    5

    Default

    You neeed
    servlet-api.jar
    on your classpath

    If you use Tomcat you can find it in path that looks like this:
    C:\apache-tomcat-6.0.20\lib

Similar Threads

  1. servlets
    By priyacvr in forum Java Servlet
    Replies: 2
    Last Post: 09-28-2009, 07:43 AM
  2. Compile Servlets with Apache ANT
    By Lukas in forum Advanced Java
    Replies: 2
    Last Post: 08-06-2009, 11:39 AM
  3. Servlets
    By javahelp00 in forum New To Java
    Replies: 1
    Last Post: 02-28-2009, 06:28 PM
  4. servlets or jsp
    By krishnapal in forum Advanced Java
    Replies: 1
    Last Post: 12-13-2007, 02:31 PM
  5. Servlets
    By nagaroopanandha in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 02:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •