[undertow-dev] When to use RequireWelcomeFileMapping

Brad Wood bdw429s at gmail.com
Wed Aug 14 09:26:07 EDT 2019


Thanks for the reply Stuart.  The javadoc isn't really prescriptive enough
however.  I'm parsing a web.xml and adding servlets dynamically.  In that
manner, how would I know if a given servlet was going to serve JSPs or was
the default servlet?

You are unlikely to ever need this unless you have a servlet that processes
> or serves resources and want to perform welcome file mappings.


Well, yes, that actually applies to me :) I'm using Undertow to start up
ColdFusion servers which in addition to usually running JSP if you want,
use wildcard mappings and have welcome files.  A ColdFusion server has
several mappings in place though.  In addition to the wildcard ones similar
to *.cfm or /index.cfm/* it also has mappings for /flex2gateway/* and I'm
seeing incorrect behavior where my welcome files are getting crammed into
the flex gateway URLs where they don't belong, thus my question.

But my code isn't manually creating the mappings.  Like I said above, I'm
parsing a web.xml and adding the mappings dynamically, which puts me back
to my original question.  I don't think RequireWelcomeFileMapping should be
set for all mappings, but I'm unclear on how to tell the difference
programmatically.  How do other servlets such as Tomcat handle this when
loading my mappings from my web.xml?

I'm attaching an example web.xml so you can see what I'm talking about.

Thanks!

~Brad

*Developer Advocate*
*Ortus Solutions, Corp *

E-mail: brad at coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com



On Wed, Aug 14, 2019 at 12:57 AM Stuart Douglas <sdouglas at redhat.com> wrote:

> This is mostly for JSP, as per the javadoc on the field:
> https://jar-download.com/artifacts/io.undertow/undertow-servlet/2.0.24.Final/source-code/io/undertow/servlet/api/ServletInfo.java
>
>
> Say we have mapped a JSP servlet to /jsp/*, and this directory contains a
> file called index.jsp. Even though we have technically mapped to a servlet
> we still want to perform a welcome file match to actually serve
> /jsp/index.jsp via the welcome file mechanism. It's a similar story for the
> default servlet, if there is an index.html it should serve that via a
> welcome file.
>
> You are unlikely to ever need this unless you have a servlet that
> processes or serves resources and want to perform welcome file mappings.
>
> Stuart
>
> On Thu, 1 Aug 2019 at 07:28, Brad Wood <bdw429s at gmail.com> wrote:
>
>> I have some questions about when I should be using the following:
>>
>> servletInfo.setRequireWelcomeFileMapping(true)
>>
>> I can't find any documentation or comments in the code that help me
>> answer exactly what that setting does and when to use it.  I'm parsing a
>> web.xml file and creating the proper deployment from it, but I'm unsure
>> when to set the option above since there is no corresponding attribute or
>> tag in a web.xml along those lines.
>>
>> I did find this comment in a code sample online
>>
>> //if the JSP servlet is mapped to a path that ends in /*
>> //we want to perform welcome file matches if the directory is requested
>>
>> *(
>> https://jar-download.com/artifacts/io.undertow/undertow-jsp/1.0.0.Beta27/source-code/io/undertow/jsp/JspServletBuilder.java
>> <https://jar-download.com/artifacts/io.undertow/undertow-jsp/1.0.0.Beta27/source-code/io/undertow/jsp/JspServletBuilder.java>
>> )*
>>
>> but my app server has more than one servlet mapping with URL filters
>> ending with /* and the welcome file list should only apply to one of them
>> so it doesn't seem correct that ALL url filters ending in /* should set
>> that. I'm unclear on whether the welcome files are attempted up front or
>> only if a matching url filter isn't found.
>>
>> Thanks!
>>
>> ~Brad
>>
>> *Developer Advocate*
>> *Ortus Solutions, Corp *
>>
>> E-mail: brad at coldbox.org
>> ColdBox Platform: http://www.coldbox.org
>> Blog: http://www.codersrevolution.com
>>
>> _______________________________________________
>> undertow-dev mailing list
>> undertow-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20190814/a0e02292/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: web.xml
Type: text/xml
Size: 27494 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/undertow-dev/attachments/20190814/a0e02292/attachment-0001.xml 


More information about the undertow-dev mailing list