Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 :)

like image 686
Neilos Avatar asked Jan 21 '13 18:01

Neilos


2 Answers

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!

like image 192
Neilos Avatar answered Sep 16 '22 22:09

Neilos


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

like image 20
Rafael Companhoni Avatar answered Sep 20 '22 22:09

Rafael Companhoni