Results 1 to 4 of 4
  1. #1
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Question my first servlet

    Hi everyone,
    i just installed tomcat5.5 in my system.i wrote my first servlet program(.java) like below...
    Java Code:
    import javax.servlet.*;
    import java.io.*;
    public class servlet1 extends GenericServlet
    {
      public void service(Servletrequest req,ServletResponse res)
      {
        PrintWriter pw=res.getWriter();
        pw.println("Hi,this is my first servlet program.");
      } 
    }
    But when i am trying to compiling this file, i am getting errors like below..
    Java Code:
    E:\WINDOWS\servlets>javac servlet1.java
    servlet1.java:1: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    servlet1.java:3: cannot resolve symbol
    symbol  : class GenericServlet
    location: class servlet1
    public class servlet1 extends GenericServlet
                                  ^
    servlet1.java:5: cannot resolve symbol
    symbol  : class Servletrequest
    location: class servlet1
      public void service(Servletrequest req,ServletResponse res)
                          ^
    servlet1.java:5: cannot resolve symbol
    symbol  : class ServletResponse
    location: class servlet1
      public void service(Servletrequest req,ServletResponse res)
                                             ^
    4 errors
    what's wrong with my code...is there any problem with my classpath ?what i have to give for classpath? is it necessary to change any other system variables ?
    All other programs which doesn't involve the concept of servlets were compiled fine in my system.
    This is the first time i am working with servlets..so i am getting so many doubts..please help me..

    Thankq so much.
    sireesha.

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

  3. #3
    Join Date
    Mar 2008
    Posts
    13
    Rep Power
    0

    Default

    u copy servlet-api.jar into u r current folder where u r running java proram
    and set the classpath like following
    set CLASSPATH=servlet-api.jar;.
    try and compile
    may be its very help ful to u

    Geeta

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

Similar Threads

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