Results 1 to 7 of 7

Thread: Servlet

  1. #1
    banie is offline Member
    Join Date
    Jan 2008
    Posts
    21
    Rep Power
    0

    Default Servlet

    Hi,

    I just newbie using java and still learn about using servlet. I implement java source code, seem it direct show the code. And also got those error:

    Java Code:
    TestingServlet.java:1: package javax.servlet does not exist
    import javax.servlet.*; 
    ^
    TestingServlet.java:2: package javax.servlet.http does not exist
    import javax.servlet.http.*; 
    ^
    TestingServlet.java:6: cannot find symbol
    symbol: class HttpServlet
    public class TestingServlet extends HttpServlet {
                                        ^
    TestingServlet.java:8: cannot find symbol
    symbol  : class HttpServletRequest
    location: class TestingServlet
      public void doGet(HttpServletRequest request, 
                        ^
    TestingServlet.java:9: cannot find symbol
    symbol  : class HttpServletResponse
    location: class TestingServlet
        HttpServletResponse response) 
        ^
    TestingServlet.java:10: cannot find symbol
    symbol  : class ServletException
    location: class TestingServlet
        throws ServletException, IOException {
               ^
    6 errors
    my code:
    Java Code:
    import javax.servlet.*; 
    import javax.servlet.http.*; 
    import java.io.*; 
    import java.util.*; 
    
    public class TestingServlet extends HttpServlet {
    
      public void doGet(HttpServletRequest request, 
        HttpServletResponse response) 
        throws ServletException, IOException {
    
        PrintWriter out = response.getWriter(); 
        out.println("<HTML>"); 
        out.println("<HEAD>"); 
        out.println("<TITLE>Servlet Testing</TITLE>"); 
        out.println("</HEAD>"); 
        out.println("<BODY>"); 
        out.println("Welcome to the Servlet Testing Center"); 
        out.println("</BODY>"); 
        out.println("</HTML>"); 
      } 
    }

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Hello,

    servlet-api.jar is missing, just add into classpath or put at proper place.



    sanjeev

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    I'm not an expert on servlets... but after some searching around, it appears this is a common error when folks don't have their javax.servlet library properly installed or their server on and/or configured. Do a search for "servlet" in the Java Tutorials section of this site.. or just do a basic search for "servlet" and you might just find your answer.
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by CaptainMorgan View Post
    don't have their javax.servlet library properly installed or their server on and/or configured.
    Yep, I think so. There is a common error message, directed that import package is not perfectly execute.

  5. #5
    banie is offline Member
    Join Date
    Jan 2008
    Posts
    21
    Rep Power
    0

    Default

    Where to get servlet-api.jar? My geronimo run in /var/geronimo/

    You mean add into that directory?

  6. #6
    javarishi is offline Member
    Join Date
    Apr 2008
    Posts
    91
    Rep Power
    0

    Default

    Which Server Are You Using?, Apache Geronimo? Ok AnyWay This is Freely downloadable. Just Google It. Put It Inside Lib Dir Of Your App.

  7. #7
    banie is offline Member
    Join Date
    Jan 2008
    Posts
    21
    Rep Power
    0

    Default

    I'm using Geronimo Apache ver 2.0. If i want to run that servlet, i have to put .class in classes folder, am i right?

    But in folder WEB-INF don't have classes file. That mean i have to create it? What else i should do to run that servlet?

    Why it show those error when i compile it, before i add in geronimo?
    Last edited by banie; 04-11-2008 at 06:20 PM.

Similar Threads

  1. Servlet vs JSP
    By javaplus in forum Java Servlet
    Replies: 5
    Last Post: 06-26-2008, 11:19 PM
  2. Regarding Servlet
    By Sudha in forum New To Java
    Replies: 1
    Last Post: 02-12-2008, 01:44 AM
  3. JSP or Servlet
    By ravian in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-03-2007, 04:00 PM
  4. How to mix servlet & JSP
    By Swamipsn in forum Java Servlet
    Replies: 1
    Last Post: 08-08-2007, 01:57 AM
  5. Replies: 1
    Last Post: 08-07-2007, 04:47 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
  •