Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2011
    Location
    India
    Posts
    67
    Rep Power
    0

    Default Servlet Compiling Error

    Hello sir,
    The following is the servlet program:

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http;
    public class FirstServlet extends HttpServlet
    {
    public void doGet(HttpServletRequest req,HttpServletResponse res)throws Exception
    {
    res.setContentType("text/html");
    PrintWriter out=res.getWriter();
    out.println("<html>");
    out.println("<head><title>FirstServlet</title></head><body>Hello</body></html>");
    }
    }

    i already set environment variabls.

    When i complie this i got 4 errors

    the error is can't find symbol HttpServlet


    plz tell me how solve this problem


    thank you in advance

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default Re: Servlet Compiling Error

    You do need to have a .jar file with the HttpServlet class in it on your classpath.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Join Date
    Sep 2011
    Location
    India
    Posts
    67
    Rep Power
    0

    Default Re: Servlet Compiling Error

    Quote Originally Posted by JosAH View Post
    You do need to have a .jar file with the HttpServlet class in it on your classpath.

    kind regards,

    Jos
    Sir i have .jar file also and i set classpath also
    the classpath=C:\Program Files\Java\jdk1.7.0\lib;C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.34\lib\servlet-api.jar;
    still i geting errors

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: Servlet Compiling Error

    If this is correct:
    Java Code:
    import javax.servlet.http;
    then you are not importing the class.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    Join Date
    Sep 2011
    Location
    India
    Posts
    67
    Rep Power
    0

    Default Re: Servlet Compiling Error

    Quote Originally Posted by Tolls View Post
    If this is correct:
    Java Code:
    import javax.servlet.http;
    then you are not importing the class.
    thankx sir. now the problem was solved. thank you

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,710
    Rep Power
    5

    Default Re: Servlet Compiling Error

    Are you using an IDE? Usually you can let it "fix imports" for you. For example using Eclipse you'd press CTRL+SHIFT+O, but it is also in a menu somewhere.

Similar Threads

  1. Servlet compiling error
    By sathishvegeta in forum New To Java
    Replies: 5
    Last Post: 05-18-2013, 09:30 AM
  2. Compiling a Servlet!!
    By f22raptor in forum New To Java
    Replies: 0
    Last Post: 10-04-2011, 05:12 PM
  3. compiling error
    By Adeline in forum AWT / Swing
    Replies: 3
    Last Post: 12-03-2010, 07:19 PM
  4. java servlet not compiling
    By aks_1 in forum New To Java
    Replies: 6
    Last Post: 05-03-2010, 12:34 PM
  5. problem compiling servlet
    By vivek_9912 in forum Java Servlet
    Replies: 1
    Last Post: 02-13-2009, 11:37 AM

Posting Permissions

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