views:

8

answers:

1

Im making an easy application just to test the JSF framework.

This is actually web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
    <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

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

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>faces/index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

and faces.config.xml :

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE faces-config PUBLIC
  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"&gt;

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config>
    <navigation-rule>
        <from-view-id>/index.jsp</from-view-id>
        <navigation-case>
            <from-outcome>avanti</from-outcome>
            <to-view-id>/pagina1.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>

    <managed-bean>
        <managed-bean-name>utente</managed-bean-name>
        <managed-bean-class>myPack.user</managed-bean-class>

        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
</faces-config>

but unfortunatly it doesnt work : Error 404 description The requested resource (/JSFTutorial/) is not available.

and of course my pages are : Source Package/myPack/user.java Web Pages/index.jsp and Web Pages/pagina1.jsp

Any idea? What im wrong? Bye

+1  A: 

Here,

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

you've configured the FacesServlet to hook on requests matching the url-pattern of *.faces. So, to open for example index.jsp, you have to open it by http://example.com/context/index.faces.

And here,

<welcome-file-list>
    <welcome-file>faces/index.jsp</welcome-file>
</welcome-file-list>

you've configured the welcome-page to listen on the wrong URL. Make it /index.faces.


By the way, *.jsf is a more common URL pattern. I'd also suggest to lookup for bit more recent tutorials/books targeting JSF 2.0. JSF 1.1 is already over 6 years old and things have changed a lot.

BalusC
Thanks for the reply. Anyway, im using Netbeans, and i start the project with usual Play button. How can configure it which automatically set the URL as index.faces?
markzzz
Sorry, I don't use Netbeans, I threw it away after 5 minutes of trying some years back. Consider asking a new question, this is at least unrelated to the current question.
BalusC