This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Qn on welcome-file-lsit tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Qn on welcome-file-lsit tag" Watch "Qn on welcome-file-lsit tag" New topic
Author

Qn on welcome-file-lsit tag

Chandra Sagi
Ranch Hand

Joined: May 05, 2005
Posts: 162
Hi Ranchers,

Could there be more than one occurance of <welcome-file-list> tag in a DD. Please confirm.

Thanks in Advance
Chandu
Cm Ananth
Ranch Hand

Joined: Oct 20, 2005
Posts: 44
Yes. Its possible to mention more than one welcome file name inside the <welcome-file-list> tag.. The welcome file will be called depends upon the location request..

Correct me if something is wrong..


By Ananth, Bangalore
Shanmu Arumugam
Greenhorn

Joined: Mar 22, 2006
Posts: 14
Hi, though <welcome-file-list> is optional tag, more than one occurance is not possible. one per webapp. <welcome-file> can be more than one. correct me if i'm wrong.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

The <welcome-file-list> element define the ordered list of files to look for the directory. There can be more than one element of this type. If more than one entries present in the web.xml, the container mergers them in oreder they define in the web.xml.

Hope it help

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
From the servlet spec 2.4 (SRV 13.3), from the XML-Schema of the DD, some elements are in a xsd:choice element with this definition :



Which means elements declared in this choice block can be used (minOccurs) to any times (no limit, as unbounded value of maxOccurs tells us).

In these elements you find :

  • welcome-file-list
  • servlet
  • servlet-mapping
  • mime-mapping
  • error-page
  • jsp-config
  • etc...


  • This proves that welcome-file-list element may appear 0 to multiple times in a DD.

    About the welcome-file sub-elements, they are defined in the welcome-file-listType complex type this way :


    This means they can appear 1 (no minOccurs attributes, default for xsd:element is 1) to many (maxOccurs set to unbounded).

    So in a welcome-file-list, you must have at least one welcome-file, but beside this rule, you may have as many as you wish.

    Specs always help
    [ March 22, 2006: Message edited by: Frederic Esnault ]

    SCJP 5 - SCWCD 1.4 - SCBCD 1.3 - Certification study documents/resources: http://esnault.frederic.free.fr/certification
    Christophe Verré
    Sheriff

    Joined: Nov 24, 2005
    Posts: 14687
        
      16

    hum... As if there was not enough people answering here,
    I'll add my little spice.

    In the spec, looking at the nice diagrams in "SRV.13.4 Deployment Descriptor Diagram" is much easier to understand. To check for mandatory tags, subtags, etc..., it is very handy.


    [My Blog]
    All roads lead to JavaRanch
    Frederic Esnault
    Ranch Hand

    Joined: Feb 13, 2006
    Posts: 284
    Yes you're right, it's simple, but this is a schematic translation of the XML Schema. And the XSD (XML-Schema) defines very clearly the occurences allowed, and should be the last reference when in doubt.

    But knowing the schema translates the XSD, then you're right. I just didn't want to say "look at the star in from of the welcome-file-list block in the schema, it means 0 o many". So I explained deeply.

    I'm sorry, i'll never do it again
    Narendra Dhande
    Ranch Hand

    Joined: Dec 04, 2004
    Posts: 950
    Hi fred,

    I'm sorry, i'll never do it again


    Sorry for what ? You are doing really good job. Not everybody can do this. Please carry on.

    Thanks
    Chandra Sagi
    Ranch Hand

    Joined: May 05, 2005
    Posts: 162
    Thanks friends. In the book it said it cannot have more than one. In one mock exam it was the other answer. Thanks for clearing my doubt.

    Cheers
    Chandu
    Gunaselan Varathan
    Ranch Hand

    Joined: Nov 11, 2005
    Posts: 30
    Hi Guys,
    I understand that <welcome-file-list> can appear multiple times, but i have a question, if we declare <welcome-file-list> what is the order of processing,

    ex:
    <welcome-file-list>
    <welcome-file> index.html</welcome-file>
    <welcome-file> index.do</welcome-file>
    </welcome-file-list>

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

    in this scenario, can we predict the behaviour.


    Guna<br />SCJP 1.4 86<br />SCWCD 1.4 94
    Christophe Verré
    Sheriff

    Joined: Nov 24, 2005
    Posts: 14687
        
      16

    Originally posted by Narendra Dhande:

    Sorry for what ? You are doing really good job. Not everybody can do this. Please carry on.
    Thanks


    Haha. You don't even know what your own signature means (or seems to mean):
    "Man is always sorry for what is not"
    Narendra Dhande
    Ranch Hand

    Joined: Dec 04, 2004
    Posts: 950
    Hi Satou,

    My mother tongue is not english and my english is not so good. I am using this signature from lot of year, no one had any comments on it. I really appreciate if you can tell me what is wrong with this signature.

    Thanks
    Christophe Verré
    Sheriff

    Joined: Nov 24, 2005
    Posts: 14687
        
      16

    Hi Narendra,
    I was just kidding English is not my mother tongue either.

    I thought it meant something like "Man is always sorry for what he should not be sorry for".
    Meaning that you should not tell Fred not to be sorry, because man is always sorry for what he should not be sorry for. Hummmmm... I'm lost

    Anyway, you were right about him doing a really good job.
    Gunaselan Varathan
    Ranch Hand

    Joined: Nov 11, 2005
    Posts: 30
    Hi Guys,
    In this scenario
    <welcome-file-list>
    <welcome-file> index.html</welcome-file>
    <welcome-file> index.do</welcome-file>
    </welcome-file-list>

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

    it is treated as

    <welcome-file-list>
    <welcome-file> index.html</welcome-file>
    <welcome-file> index.do</welcome-file>
    <welcome-file> index.jsp</welcome-file>
    </welcome-file-list>

    I tested this in tomcat 5.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Qn on welcome-file-lsit tag
     
    Similar Threads
    requested resource() not found for simple HTML?
    problem in struts
    what should be the first servlet to display when application launches?
    Diiference between <welcome-file-list> tag and <load-on-startup> tag in web.xml file of servlet
    automatically invoking jsp