index.html not displaying for my WebApp (Tomcat 7 in Eclipse)

17,016

Solution 1

Ahh my last comment just made me realise something. I was being a bit silly. I simply had my index.html in the wrong location, it shouldn't be under WEB-INF but under WebContent (the parent directory of WEB-INF). The 404 was in fact the massive hint, everything was working correctly except me! Doh!

Solution 2

In your web.xml file you should have something like this :

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
    <url-pattern>*.jsf</url-pattern>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

This way you're mapping url patterns to servlets. In this example, you access index.xhtml, index.jsf or .../faces/index

Share:
17,016
Neilos
Author by

Neilos

Updated on June 07, 2022

Comments

  • Neilos
    Neilos almost 2 years

    I have Tomcat 7 with Servlet 3.0 running in Eclipse.

    Under my WEB-INF folder I placed two files, web.xml and index.html. The web.xml defines the welcome-file as index.html however when I go to

    http://localhost:8080/WebApp/
    

    I get a 404.

    Strange thing is that I have a servlet defined as /login and when I go to

    http://localhost:8080/WebApp/login
    

    I can see and use the servlet (I can debug it and see my doGet() request)

    I have no idea why I cannot see the welcome file, It did work a while ago but I have made some changes since then, I changed how I connect to a database by setting up a Connection Pool as Tomcat starts but this shouldn't have affected much. Not quite sure where to look next, catalina.out gives no hints.

    Can anyone see why my welcome file is not functioning as I want? Any help appreciated :)

  • Neilos
    Neilos over 11 years
    Forgive me if I am wrong but I don't want to map anything to a servlet (except for the ones I ahve already mapped). It is just that I am not finding my welcome file.