Tomcat 4.1 ROOT servlet mapping.

Discussion in 'Java' started by F. H., Aug 21, 2004.

  1. F. H.

    F. H. Guest

    Around a year ago I remember it being absolutely impossible to
    configure tomcat to have something like:

    http://www.example.com/

    map to a servlet; you have to have http://www.example.com/index.jsp
    instead.

    Anyways, if I just want to have http://www.example.com/index be a
    servlet what do I put in web.xml? It seems like servlet names like
    /index won't work in the welcome-file-list.

    As a last resort I could put index.html in the welcome-file-list and
    have index.html redirect to the /index servlet, but this means
    everytime a user loads http://www.example.com/ they are first
    redirected to /index.html and then redirected to /index. It's really
    stupid that two redirects should be necessary because of Tomcat's lack
    of configurability.

    Ugh, I hate Tomcat and don't know why such a simple thing that's so
    easy with Apache+Perl is so hard with a supposedly "superior
    technology." Why can't I just have http://www.example.com/ be a
    servlet?
    Anyways, I'll settle for http://www.example.com/index if someone can
    show me how to configure Tomcat to serve /index when
    http://www.example.com/ is requested.

    Also, has the situation improved with Tomcat 5?
    F. H., Aug 21, 2004
    #1
    1. Advertising

  2. On 21 Aug 2004 14:07:36 -0700, F. H. <> wrote:

    > Around a year ago I remember it being absolutely impossible to
    > configure tomcat to have something like:
    >
    > http://www.example.com/
    >
    > map to a servlet; you have to have http://www.example.com/index.jsp
    > instead.
    >
    > Anyways, if I just want to have http://www.example.com/index be a
    > servlet what do I put in web.xml? It seems like servlet names like
    > /index won't work in the welcome-file-list.
    >
    > As a last resort I could put index.html in the welcome-file-list and
    > have index.html redirect to the /index servlet, but this means
    > everytime a user loads http://www.example.com/ they are first
    > redirected to /index.html and then redirected to /index. It's really
    > stupid that two redirects should be necessary because of Tomcat's lack
    > of configurability.
    >
    > Ugh, I hate Tomcat and don't know why such a simple thing that's so
    > easy with Apache+Perl is so hard with a supposedly "superior
    > technology." Why can't I just have http://www.example.com/ be a
    > servlet?
    > Anyways, I'll settle for http://www.example.com/index if someone can
    > show me how to configure Tomcat to serve /index when
    > http://www.example.com/ is requested.
    >
    > Also, has the situation improved with Tomcat 5?


    Tomcat has always had a servlet mapped to /

    <!-- The mapping for the default servlet -->
    <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>

    Just look at your server.xml, replace the "default" with the name of
    the servlet you want, and there you are. Its easy with a "superior
    technology" - but you have to do some reading.


    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
    William Brogden, Aug 21, 2004
    #2
    1. Advertising

  3. F. H.

    F. H. Guest

    "William Brogden" <> wrote in message news:<opsc3ri7g8k0yerx@ruby>...
    > On 21 Aug 2004 14:07:36 -0700, F. H. <> wrote:
    >
    > > Around a year ago I remember it being absolutely impossible to
    > > configure tomcat to have something like:
    > >
    > > http://www.example.com/
    > >
    > > map to a servlet; you have to have http://www.example.com/index.jsp
    > > instead.
    > >
    > > Anyways, if I just want to have http://www.example.com/index be a
    > > servlet what do I put in web.xml? It seems like servlet names like
    > > /index won't work in the welcome-file-list.
    > >
    > > As a last resort I could put index.html in the welcome-file-list and
    > > have index.html redirect to the /index servlet, but this means
    > > everytime a user loads http://www.example.com/ they are first
    > > redirected to /index.html and then redirected to /index. It's really
    > > stupid that two redirects should be necessary because of Tomcat's lack
    > > of configurability.
    > >
    > > Ugh, I hate Tomcat and don't know why such a simple thing that's so
    > > easy with Apache+Perl is so hard with a supposedly "superior
    > > technology." Why can't I just have http://www.example.com/ be a
    > > servlet?
    > > Anyways, I'll settle for http://www.example.com/index if someone can
    > > show me how to configure Tomcat to serve /index when
    > > http://www.example.com/ is requested.
    > >
    > > Also, has the situation improved with Tomcat 5?

    >
    > Tomcat has always had a servlet mapped to /
    >
    > <!-- The mapping for the default servlet -->
    > <servlet-mapping>
    > <servlet-name>default</servlet-name>
    > <url-pattern>/</url-pattern>
    > </servlet-mapping>
    >
    > Just look at your server.xml, replace the "default" with the name of
    > the servlet you want, and there you are. Its easy with a "superior
    > technology" - but you have to do some reading.


    But the mapping to '/' is really a mapping to '/*' --- that is, EVERY
    url is then mapped to my servlet so now http://www.example.com/asdfxyz
    maps to my servlet instead of giving a 404. The serving of all
    filetypes and responses is broken this way because now my servlet
    wants to be the default one that serves *.gif, *.html, 404 errors, and
    so forth. I suppose it might be possible to have my servlet check if
    the request is for something other than '/' and then pass the request
    to the org.apache.catalina.servlets.DefaultServlet class if it is....
    F. H., Aug 22, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    1,993
    Jack Jia
    Apr 4, 2004
  2. Sean Berry
    Replies:
    3
    Views:
    4,548
    Tim Terry
    Dec 19, 2005
  3. Philippe Poulard

    [Tomcat] Mapping to the default servlet

    Philippe Poulard, Jun 20, 2006, in forum: Java
    Replies:
    0
    Views:
    749
    Philippe Poulard
    Jun 20, 2006
  4. evgchech

    Tomcat servlet-mapping question

    evgchech, Jul 18, 2007, in forum: Java
    Replies:
    0
    Views:
    303
    evgchech
    Jul 18, 2007
  5. Replies:
    0
    Views:
    469
Loading...

Share This Page