5 Replies Latest reply on Mar 19, 2006 8:29 PM by treespace

    Servlet welcome-file not working

    treespace Novice

      Using JBoss 4.0 with Tomcat (5.X) and added a servlet name as a welcome file in my webapp. 2.4 servlet container claims you can do this. Rather than providing a file you just drop in a servlet name as-is with no slashes or any other baggage; just the servlet net.

      Anybody have this working? My servlet is not called. In fact, the default tomcat servlet is called and I get a directory listing! There are no runtime errors or deployment errors.

        • 1. Re: Servlet welcome-file not working
          Joshua Preston Newbie

          treespace,

          Please post all of your relevant configuration files.

          Thanks!

          Joshua Preston.

          • 2. Re: Servlet welcome-file not working
            treespace Novice

            Just add a servlet, with or without a servlet mapping:


            <servlet-name>Navigator</servlet-name>
            <servlet-class>com.acme.Navigator</servlet-class>


            Try using "Navigator" as a welcome-file:

            <welcome-file-list>
            <welcome-file>Navigator</welcome-file>
            </welcome-file-list>


            If the war file is "acme" then http://localhost/acme will NOT go to the Navigator servlet. Instead the default tomcat servlet is called and you get a directory listing.

            • 3. Re: Servlet welcome-file not working
              treespace Novice

              Workaround until servlet welcome-files are fixed:

              Use a static welcome file...

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

              Containing the following script element...

              < body>
              < script type="text/javascript">window.location="/navigator"</ script >
              hang on buddy...
              </ body>

              Add query string arguments as needed by your controller, e.g., /navigator?action=home




              • 4. Re: Servlet welcome-file not working
                Scott Stark Master

                A welcome file servlet requires a mapping like:

                <welcome-file-list>
                 <welcome-file>WelcomeServlet</welcome-file>
                </welcome-file-list>
                
                <servlet>
                 <servlet-name>WelcomeServlet</servlet-name>
                 <servlet-class>...</servlet-class>
                </servlet>
                
                <servlet-mapping>
                 <servlet-name>WelcomeServlet</servlet-name>
                 <uri-pattern>*.welcome</uri-pattern>
                </servlet-mapping>
                


                and a matching (can be empty since its ignored) static file such my.welcome under each path where the welcome servlet is to be invoked.


                • 5. Re: Servlet welcome-file not working
                  treespace Novice

                  I did not see any mention of a dummy static welcome file mapping in the 2.4 servlet specfiication. Whatever works I suppose. I think I will stick with the bona fide static welcome file that sets the window location. That also works.

                  Thanks for the feedbackScott.