Hello all,

Suppose I'm running slashdot.org 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

   http://slashdot.org/

into their browser and goes there they won't be redirected to
http://slashdot.org/index. The real slashdot.org doesn't automatically
redirect you to index.pl. You just see http://slashdot.org/ 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

  <!-- ... -->
  <servlet-mapping>
    <servlet-name>index</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>article</servlet-name>
    <url-pattern>/article</url-pattern>
  </servlet-mapping>
  <!-- ... -->

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:
    <!-- ... -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.gif</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.css</url-pattern>
    </servlet-mapping>
    <!-- ... -->

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
bunch!
             A.Z.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to