Hi Martin,

Thanks for your reply.

My Apache Tomcat version is 5.5.27. The servlet-api.jar is in
$CATALINA_HOME/common/lib. I included it in the classpath and now the code
compiles without any errors.

I am including my web.xml file below.

Please let me know what else I need to do to get the servlet to work, and
how to access it later on.

Thanks again.
Anand


-- web.xml --

<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
    version="2.4">

  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>

<!-- JSPC servlet mappings start -->

    <servlet>
        <servlet-name>org.apache.jsp.index_jsp</servlet-name>
        <servlet-class>org.apache.jsp.index_jsp</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>org.apache.jsp.index_jsp</servlet-name>
        <url-pattern>/index.jsp</url-pattern>
    </servlet-mapping>

<!-- JSPC servlet mappings end -->

</web-app>







On Mon, Jun 8, 2009 at 4:37 AM, Martin Gainty <mgai...@hotmail.com> wrote:

>
> is servlet-api.jar on classpath
> usually located at $CATALINA_HOME\lib\servlet-api.jar
>
> what does your web-inf/web.xml look like?
> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
> > Date: Mon, 8 Jun 2009 04:25:36 -0700
> > Subject: Servlet Error
> > From: listan...@gmail.com
> > To: users@tomcat.apache.org
> >
> > Hi all,
> >
> > I am new to Tomcat/Apache, and have just about started to learn
> JSP/Servlets
> > as well.  I just wrote my first Hello world servlet (code below) and
> tried
> > to run it, but got several errors. Here's exactly what I did:
> > 1. I wrote "Hello.java" (code below) and put it in /webapps/ROOT
> directory
> > 2. I tried to compile it ("javac Hello.java") but got errors. (see below)
> >
> > I would appreciate if someone would tell me what I am missing. Also,
> after
> > the servlet compiles, do I need to put it in WEB-INF?
> >
> > Just for the records, I try to access the servlet using
> > http://localhost:8080/Hello and I am using Java version 1.6.
> >
> > Thanks in advance.
> >
> >
> >
> > ---CODE---
> > import java.io.*;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> >
> > public class Hello extends HttpServlet {
> >   public void doGet(HttpServletRequest request,
> >                     HttpServletResponse response)
> >       throws ServletException, IOException {
> >     PrintWriter out = response.getWriter();
> >     out.println("Hello World");
> >   }
> > }
> >
> >
> >
> > --ERRORS--
> >
> > Hello.java:2: package javax.servlet does not exist
> > import javax.servlet.*;
> > ^
> > Hello.java:3: package javax.servlet.http does not exist
> > import javax.servlet.http.*;
> > ^
> > Hello.java:5: cannot find symbol
> > symbol: class HttpServlet
> > public class Hello extends HttpServlet {
> >                            ^
> > Hello.java:6: cannot find symbol
> > symbol  : class HttpServletRequest
> > location: class Hello
> >   public void doGet(HttpServletRequest request,
> >                     ^
> > Hello.java:7: cannot find symbol
> > symbol  : class HttpServletResponse
> > location: class Hello
> >                     HttpServletResponse response)
> >                     ^
> > Hello.java:8: cannot find symbol
> > symbol  : class ServletException
> > location: class Hello
> >       throws ServletException, IOException {
> >              ^
> > 6 errors
>
> _________________________________________________________________
> Hotmail® has ever-growing storage! Don’t worry about storage limits.
>
> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009
>

Reply via email to