Error in my first JSF program. Tomcat and Eclipse

I am new to Java. I am using eclipse Helios and Tomcat 7.

I set up the server and wrote my first JSF page, but I got this error:

HTTP Status 404 - /
type Status report
message /
description The requested resource (/) is not available.
Apache Tomcat/7.0.27

First Page Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <title>JSF 2.0 Hello World</title>
    </h:head>
    <h:body>
        <h3>JSF 2.0 Hello World Example - hello.xhtml</h3>

    </h:body>
</html>

Then I changed the port to 8088. But when I type localhost:8088in my browser, I get the same error.

+3
source share
4 answers

This can be caused by several common reasons:

  • Most likely you are trying to access something similar at startup: localhost: 8080 / MyProject /

    To do this, you will need to specify a list of welcome files in your web.xml:

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

    Also add these lines to indicate the display of the servlet if you do not already have them:

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

    , index.xhtml -.

  • .xhtml, - Wep-.

  • .xhtml, .

, : resource (/), , , .

, !

+8

Tomcat jsf libs. jsf lib \apache-tomcat\lib. , .

+6

, ,

jsf, url "localhost: 8088\faces\test.jsp" , , URL- , conatins url pattren, facesServlet, jsf lifecycle

URL (.. web.xml) , , localhost\8080\facesservlet , .

web.xml

*.xhtml

, , URL- *.xhtml, .

web.xml

<servlet-mapping>    <servlet-name>Faces servlet</servlet-name>    <url-pattern>/faces/*</url-pattern>   </servlet-mapping>

URL "" URL-. . anil sharma

0

jsf, lib WEB-inf, : → → Java → JSF_lib-- > ,

0

All Articles