I think that you can acheive what you are trying to do by putting
the following definitionin in your web.xml file:

    <error-page>
        <error-code>404</error-code>
        <location>/favorite_servlet_url</location>
    </error-page>

If someone types in a url that does not exist the 404 File Not Found
will result in you favorite servlet being displayed, instead of the
default 404 message.

Similarly, if you disallow indexing on directories in your web server,
you can put this entry in web.xml:

    <error-page>
        <error-code>403</error-code>
        <location>/favorite_servlet_url</location>
    </error-page>

Then, when a user requests a url such as

http://machine/webapp/

instead of a 403 Access Forbidden message your users will see your
favorite servlet again.

Of course, what you can do with the Web Application descriptors is not
nearly as powerful as what you can do with Apache mod_rewrite.

Alex Amies

-----Original Message-----
From: Milt Epstein [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 01, 2001 10:04 PM
To: [EMAIL PROTECTED]
Subject: Servlet as default "page" for web app


I just started using Tomcat, and hence the 2.2 servlet spec.  But I
don't think this is anything specific to Tomcat, it seems like it just
has to do with what the 2.2 servlet spec allows.

What I'm trying to do is have a URL of the form:

http://some.domain.name/blah

go directly to a servlet, i.e. something that normally you'd get to
with a URL of the form:

http://some.domain.name/blah/servlet/blah

I've set up blah as a webapp (i.e. a context), and essentially I'd
like a servlet to be the default "page" of the webapp.  The default
page can be a static html page (e.g. index.html) or a JSP
(e.g. index.jsp), so why not a servlet?  But I've tried a few things
with the webapp's servlet names and servlet mappings in the web.xml
file, without success.

At jakarta.apache.org, I found a similar question in the FAQ-o-matic,
and it suggested having the default index page do a redirect, and/or
using Apache's mod_rewrite.  I tried the former, both with a static
html page (and a META Refresh) and a JSP (and a RequestDispatcher
forward()), and while it works, it changes the Location: shown by the
browser to:

http://some.domain.name/blah/servlet/blah

which I'd like to avoid.  I thought maybe there was something
available via the servlet spec (and/or Tomcat) that I was missing.

I'm looking into the mod_rewrite solution as well.

Thanks.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

________________________________________________________________________
___
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

___________________________________________________________________________
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