You need to put your .class file in examples>WEB-INF>classes directory. You
can access it using the url
http://localhost:8080/examples/servlet/HelloWorld  (I assume you haven't
changed the port of tomcat). If you want to access the servlet using
http://localhost/examples/HelloWorld, you need to do the following
1. change the port of tomat to 80 from 8080 in $Tomcat_home/conf/server.xml
2. define the HelloWorld servlet in examples/WEB-INF/web.xml .
<web-app>
     .
    .
    .
   <servlet>
        <servlet-name>
            helloworld
        </servlet-name>
        <servlet-class>
            HelloWorld
        </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>
            helloworld
        </servlet-name>
        <url-pattern>
            /HelloWorld/*
        </url-pattern>
    </servlet-mapping>
    .
    .
    .
</web-app>

hope this helps,
-sourabh

----- Original Message -----
From: Ying Su <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 13, 2002 1:23 PM
Subject: Problems in configuring Tomcat


> Dear all,
> I have set up Tomcat and seen the welcome page successfully. But I can't
run servlet. For example, I wrote a simple servlet "HelloWorld.java" which
prints "hello world" in brower, then put the "HelloWorld.class" file in
Tomcat's "examples"  directory. But when I visit it by
http://localhost/examples/HelloWorld,  Tomcat gives me an error message "The
requested resource (/HelloWorld) is not available." However, jsp files could
be executed properly.  Does anyone know how to run my servlet?
>
> Thanks a lot!
>
> Sincerely
> Ying
>
��������������������������������������������������������Ӣ�칻 �&��ǧu�sS[h-
+-����6�k�.Y�(T��Sw%�עz�^n?r��azg��� �� z?�HDU,D�
��DD"��+r �z�������r �z��j�����r?�j�!S���ǫ�W��)�z����msT^�<�q��?�i���j����
�r?��� ��l�ǫ�W���mz��-�޲<�q��?٥,""HDU �i� m���� �-� ��(>�sz楳��z����?٥

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to