Hi,

There are two ways to do that: using an external redirect or using default
servlet.

1. External redirect: add line
Redirect /index.html  http://www.test.de/servlets/yourServlet
to your httpd.conf. This way when the browser requests http://www.test.de/
(which in fact requests http://www.test.de/index.html) it will be redirected
to http://www.test.de/servlets/yourServlet.
The disadvantage of using redirects is that user will see the new path in
the address bar of the browser. If that is not a problem for you, that seems
to be the easiest solution.
2. Default servlet: add definition of the default servlet to your web.xml
for the ROOT context (TOMCAT_HOME/webapps/ROOT/web.xml):
    <servlet>
        <servlet-name>
            defaultServlet
        </servlet-name>
        <servlet-class>
            yourServletName  <!--replace this with the name of your
servlet -->
        </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>
            defaultServlet
        </servlet-name>
        <url-pattern>
            /
        </url-pattern>
    </servlet-mapping>

The disadvantage of using default servlet is that it will be called for
EVERY request to your site that is not handled by the rest of your
application, e.g.
http://www.test.de/bla_bla_bla will call this servlet (with getServletPath()
equal to "/bla_bla_bla" ) rather than raport Not Found exception.


Hope this helps,
Rafal


----- Original Message -----
From: "Alexander Klein" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 25, 2001 4:50 PM
Subject: How to use a servlet as Domain-Index


> Hi List,
>
> How can I use a Servlet as the "page" that a visitor gets when he visits
my domain directly.
> eg. When a user enters http://www.test.de then he should get the output of
my servlet.Is this possible ?
> and if so, how ?
> I am using Apache and Tomcat 3.2.1
>
> Thanky,
> Puck

Reply via email to