Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Welcome file

 
Tridib Samanta
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is an excerpt from DD of my "test" web application. Whenever I type, http://localhost:8080/test/xxx/ or http://localhost:8080/test/yyy/ I should always get the output from "Welcome Servlet" servlet. But I don't.

<servlet-mapping>
<servlet-name>Welcome Servlet</servlet-name>
<url-pattern>*.wc</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>welcome.wc</welcome-file>
</welcome-file-list>



Could you explain what's going wrong?
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Accordinlgy to HFSJ page 593, the following sequence is used to "find" the client's requested URL:

1) Container looks in the DD for a servlet mapping.
2) If a mapping cannot be found, the Container looks in the welcome-file-list, and starting from the first entry it founds, it tries to locate the specified welcome file within the directory received in the request.

In your case, the url doesn't match the servlet-mapping, and then there is no welcome.wc file in those directories.
[ March 27, 2007: Message edited by: Sergio Tridente ]
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the spec:

If a Web container receives a valid partial request, the Web container must
examine the welcome file list defined in the deployment descriptor. The welcome file list is an ordered list of partial URLs with no trailing or leading /. The Web server must append each welcome file in the order specified in the deployment descriptor to the partial request and check whether a static resource or servlet in theWAR is mapped to that request URI. TheWeb container must send the request to the first resource in the WAR that matches. The container may send the request to the welcome resource with a forward, a redirect, or a container specific mechanism that is indistinguishable from a direct request.


The only thing I can think of is when you request /test/xxx/ the container appends the welcome.wc from the welcome-file-list and first searches for a static resource with the name "welcome.wc" in the /test/xxx/ directory. If that does not exist (in this case) it looks for a servlet which is (statically?!) mapped to /test/xxx/welcome.wc, which in this case there is none... A lousy answer I know, but the *.wc url-pattern-welcome-file-list mapping simply does not seem to work. Anybody else have a good explanation?
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that your web.xml is OK and the problem you are experiencing is due to a bug in (our version of) Tomcat. I found this link in Sun's developers network forum that explains how to workaround the bug. I just did what they suggest and it worked with your original web.xml.

I hope this helps.
 
Tridib Samanta
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks much guys for your replies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic