JSF Simples

Nesta simples aplicação, como o faces controller sabe que tem que chamar login.jsp e não fronstore.jsp ?

FACES-CONFIG.XML:
<?xml version="1.0" ?>

<faces-config xmlns=“http://java.sun.com/xml/ns/javaee” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd” version=“1.2”>

<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>com.store.model.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

</faces-config>

WEB.XML:
<?xml version="1.0" ?>

<web-app xmlns=“http://java.sun.com/xml/ns/javaee” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” version=“2.5”>

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

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

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

</web-app>

LOGIN.JSP:
<html>

<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>

<f:view>

&lt;head&gt;                 
  &lt;title&gt;Log in the Online Store&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;h:form&gt;
    &lt;h3&gt;Please enter your name and password.&lt;/h3&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;Name:&lt;/td&gt;
        &lt;td&gt;
          &lt;h:inputText value="#{user.name}"/&gt;
        &lt;/td&gt;
      &lt;/tr&gt;            
      &lt;tr&gt;
        &lt;td&gt;Password:&lt;/td&gt;
        &lt;td&gt;
          &lt;h:inputSecret value="#{user.password}"/&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
    <p>
      &lt;h:commandButton value="Login" action="login"/&gt;
    </p>
  &lt;/h:form&gt;
&lt;/body&gt;

</f:view>

</html>

FRONTSTORE.JSP:
<html>

<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f” %>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h” %>

<f:view>

  &lt;head&gt;
     &lt;title&gt;The Online Store&lt;/title&gt;
  &lt;/head&gt;

  &lt;body&gt;
     &lt;h:form&gt;
        &lt;h1&gt;The Online Store&lt;/h1&gt;
        &lt;h3&gt;Welcome, &lt;h:outputText value="#{user.name}"/&gt;&lt;/h3&gt;
     &lt;/h:form&gt;
  &lt;/body&gt;

</f:view>

</html>

INDEX.HTML:
<html>
<head>
<meta http-equiv=“Refresh” content= “0; URL=index.faces”/>
<title>Start Web Application</title>
</head>
<body>

Please wait for the web application to start.


</body>
</html>