2

I am a beginner in eclipse and trying out a simple web project starting with a hello world page. But when I run the project on tomcat sever, this url is fired and I get HTTP 404 error:-

http://localhost:8080/TestWeb/

My web.xml file contents are as follows:-

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
   <display-name>TestWeb</display-name>
   <welcome-file-list>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app> 
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Soham Banerjee
  • 465
  • 1
  • 8
  • 18
  • Can u try the following : add one more servlet-mapping tag section with /faces/* and also use faces/HelloWorld.xhtml in welcome-file-list tag. – Bacteria Apr 16 '15 at 09:29
  • 2
    '/faces/*' etc should *not* be needed (nor used) in modern jsf apps anymore. And since there is no mapping in the web.xml to '/faces/* now, it can also not cause a problem. So rather ask/query for the jsf version etc... – Kukeltje Apr 16 '15 at 09:45
  • @Rin: Please stop posting nonsense. Better try to reproduce and solve the problem yourself so that you can learn by experience. – BalusC Apr 16 '15 at 10:16

1 Answers1

0

you must check the location of HelloWord.xhtml . As you have mentioned in your web.xml ,if HelloWord.xhtml is directly under WebContent then its good otherwise you will see Error-404 .

Alok Mishra
  • 926
  • 13
  • 39