Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tomcat 4.1 ROOT servlet mapping.

Reply
Thread Tools

Tomcat 4.1 ROOT servlet mapping.

 
 
F. H.
Guest
Posts: n/a
 
      08-21-2004
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?
 
Reply With Quote
 
 
 
 
William Brogden
Guest
Posts: n/a
 
      08-21-2004
On 21 Aug 2004 14:07:36 -0700, F. H. <(E-Mail Removed)> 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/
 
Reply With Quote
 
 
 
 
F. H.
Guest
Posts: n/a
 
      08-22-2004
"William Brogden" <(E-Mail Removed)> wrote in message news:<opsc3ri7g8k0yerx@ruby>...
> On 21 Aug 2004 14:07:36 -0700, F. H. <(E-Mail Removed)> 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....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat question - running tomcat webapp from root Sean Berry Java 3 12-19-2005 07:19 PM
Tomcat ssl servlet to servlet, private CA edavid3001@gmail.com Java 0 10-06-2005 09:03 PM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
Tomcat: POST from one servlet or internal class to another servlet Sean Clarke Java 1 01-07-2004 02:22 PM



Advertisments