Hey Nic and Christopher,
Thanks for the replies. As of yet I havent had much success with it
on Tomcat 4.0.1 (I'm using the one with JBoss integrated from the jboss
site). The method suggested by Jason Hunter was the one that I tried (where
I faked it into having a .jsp and .html extension) but it doesnt work either
(I get a resource not found or something like that).
Sorry about the .jsp/.html thing.. I made an assumption from the
same section of the spec that Christopher quoted.
"The web container must send the request to the first resource in
the WAR that matches."
Since it didnt work with my servlet mapping.. I took it to mean an
actual physical resource. I guess that's not what it means.
I'll try it again with the new version of Tomcat when I get a
chance.
Thanks again,
-Tim
-----Original Message-----
From: Nic Ferrier [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 24, 2002 2:09 PM
To: [EMAIL PROTECTED]
Subject: Re: Servlet for index page
"Chen, Gin" <[EMAIL PROTECTED]> writes:
> I want to have my webapplication come in to a servlet instead of a
> JSP. I know with JSPs and/or HTML index files, you can name them in the
> welcome file list. But how do you do that for a servlet?
Not all containers support doing that. However, I think that will be
fixed in a while.
You'll have to try out a few servlet containers to find out, or
consult the thread we had on this a while ago.
> I know the specs say that it has to be either a jsp or html file
I don't think the spec does say that.
> Anyhow, I've tried just putting in a mapping for the
> Servlet in welcome file. Making a new mapping for the Servlet that gives
it
> a URI with an extension of both .jsp and .html and using those in the
> welcome file list and a host of other attempted "hacks". But so far,
> no go.
>
> I've kind of fallen back to the solution of having an actual
> index.jsp that just does a jsp:forward to my Servlet for now. Still hoping
> something so easy can be done.
Jason Hunter suggested this method to me, I rather like it:
<servlet>
<servlet-name>MyIndexer</servlet-name>
<servlet-class>...</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myIndexer</servlet-name>
<uri-pattern>*.index</uri-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.index</welcome-file>
</welcome-file-list>
This ensures that the servlet recieves the full path to the
index. It's quite a clever trick.
However, as I say, not all servlet engines support this. The problem
is that many containers have taken the need for an index file to mean
"just and HTML or JSP file" and haven't implemented a servlet mapping
lookup when an index might be needed.
Nic Ferrier
___________________________________________________________________________
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