Bug 26452 - Welcome-file not forwarding to servlet
Welcome-file not forwarding to servlet
Status: CLOSED INVALID
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.0.18
Other Linux
: P3 normal with 2 votes (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2004-01-27 01:36 UTC by Seth Ladd
Modified: 2012-06-25 10:01 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seth Ladd 2004-01-27 01:36:40 UTC
Hello,

I've read the servlet spec chapters relevant to this problem, and searched the
mailing list.  I think I might have exposed a certain condition where the
welcome-file functionality isn't working correctly.

JDK: 1.4.2
Linux: 2.6.1
Tomcat: 5.0.18
Struts: 1.1

Here is my web.xml sections I believe are relevant:

----------------------------

 <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>

    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.x</url-pattern>
  </servlet-mapping>

... cut ...

	<welcome-file-list>
		<welcome-file>index.x</welcome-file>
	</welcome-file-list>

----------------------------

When I go to:

http://localhost:8080/appContext/

I see an empty directory listing.  (this is because all my jsp files are in WEB-INF)

When I go to:

http://localhost:8080/appContext/index.x

I see the correct page.

I believe, according to servlet 2.4, I should be able to place a mapping to a
servlet in the welcome-file.

I can't see any error in catalina.out or the localhost-DATE.log file.

I have no other servlets declared, and no default servlet declared.

Any ideas or tips?

Thanks very much,
Seth
Comment 1 william.barker 2004-01-27 07:31:10 UTC
This is like a really ugly use-case, but I have to agree with your reading of 
the 2.4 servlet-spec in this case.
Comment 2 Remy Maucherat 2004-01-27 08:09:06 UTC
I have to disagree: welcome files cannot possibly apply to extension mapping.
This was already discussed with Jean François a while ago.
Comment 3 Remy Maucherat 2004-01-27 08:40:10 UTC
I have one small example to add: if this bug was valid, using the spec mandated
default welcome files and servlet mappings, we would always redirect to index.jsp.
Comment 4 Seth Ladd 2004-01-27 18:23:48 UTC
OK, not sure why welcome files can't apply to extension mappings.  More
importantly, does the spec say that?  If it is implied, it should be explicitly
stated.  Reading the spec (at least, my interpretation) does not imply that
extension mappings and welcome files can't play together.

Is this a tomcat limitation or a spec limitation?

Thanks!
Comment 5 Remy Maucherat 2004-01-28 08:44:43 UTC
Look at my example. Does that behavior makes sense ? No. So you have your answer :)
Comment 6 Marcelo Bello 2004-02-18 21:53:05 UTC
I have faced the same problem. I have:
...
  <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>*.do</url-pattern>
  </servlet-mapping>
...
  <welcome-file-list>
    <welcome-file>Welcome.do</welcome-file>
  </welcome-file-list>

when I try:
http://host:port/
I get 404. if I try
http://host:port/Welcome.do works fine.

Servlet 2.4 specs says (on pdf version page 76):

"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 the WAR is mapped to that request URI."

I think its pretty clear that servlet mapping should be applied to welcome-file
elements.

Also, if I change my dd to:

...
  <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
      <servlet-name>action</servlet-name>
      <url-pattern>/Welcome.do</url-pattern>
  </servlet-mapping>
...
  <welcome-file-list>
    <welcome-file>Welcome.do</welcome-file>
  </welcome-file-list>

Everything works fine (so in this case, Tomcat is performing servlet mapping). 

It's definitely a bug.
Comment 7 Remy Maucherat 2004-02-18 21:58:38 UTC
Wow, I am so impressed by your arguments (cut & pasted from the comments right
above I'm sure) ;) If it wouldn't create a non working container, I would gladly
fix this "bug". Thanks for not reopening the report, BTW.
Comment 8 Marcelo Bello 2004-02-18 22:31:56 UTC
Remy Maucherat,

  I wonder how someone can get so arrogant. Your attitude is just not helping.
  It's pretty clear that I didn't copy&paste. As you can see, I checked the
specs, and also found a work-around (which might be helpful for other people).
  It would be nice if you could share a little bit of your acknowledge in this
matter with us, mere mortals.
  Of course it would also give credibility to your statements, so other people
won't ask again.
  In short: Why can't it be implemented?
  
  
Comment 9 Remy Maucherat 2004-02-18 22:35:58 UTC
Can you answer these two questions ?
- how is your example different from the one given on top of the page ?
- what do you think will happen, given the default configuration for all webapps
is to have index.jsp as (one of) the welcome files, with a default mapping of
*.jsp to the JSP processing servlet ? (I did point that out a few comments
above, but you don't seem to bother reading; whining is so easy ...)
Comment 10 Mauro Molinari 2012-06-25 10:01:20 UTC
Well, it's interesting to see how this "invalid" bug report and the equivalent bug #37424, classified as "nonsense" by Remy, was actually fixed in Tomcat 7 as bug #47378 ;-)