tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "A. Zazula" <>
Subject Setting up front page servlet to not use a redirect like
Date Fri, 05 Sep 2003 07:06:24 GMT
Hello all,

Suppose I'm running except coded with Java instead of
Perl. I want the main page served by a servlet named index but without
any redirects. So when the user types

into their browser and goes there they won't be redirected to The real doesn't automatically
redirect you to You just see in your
location bar. So, I tried to set this up with Tomcat and have only
found a partial-solution that isn't completely satisfactory.

My application's web.xml contains

  <!-- ... -->

  <!-- ... -->

Then, I edited the site-wide web.xml in conf/ so that the default
servlet is no longer mapped to "/" but instead to the various types my
site uses like:
    <!-- ... -->

    <!-- ... -->

If I don't do that then my images and css will no longer load. I
thought just simply making the change I made to my application's
web.xml would be sufficient, but apparently the meaning of
servlet-mapping to "/" isn't the intuitive thing of just mapping
requests for "/" to index and nothing else; it maps all other request
URIs not given servlet-mappings in those 2 web.xml files to the index
servlet instead of to the default servlet. That's what servlet-mapping
to something broader like "/*" or "/**/*" or something should do;
mapping to just "/" shouldn't give the effect it does. So if I do
http://localhost:8080/foo then I'll get the index servlet unless
foo=article or blah.gif, etc. I'd rather get a NOT FOUND message for
random URIs.

I suppose editing org.apache.catalina.servlets.DefaultServlet is a
possibilty, but there HAS to be a better approach! For example, can I
set up a default servlet that checks if the request is for "/" and if
it is then pass the request and response to the doGet (or doPost, as
the case may be) index servlet method? (And if it's not for "/" then pass
the request and response to the usual DefaultServlet method.)

This is frustrating! Any and all replies really appreciated. Thanks a

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

View raw message