I'm trying to make a page that consist of a login form, and if the user credintials are correct it will take him to another page but it doesn't seem to work.
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Name"></h:outputText>
<h:inputText value="#{validation.username}"></h:inputText>
<h:outputText value="Password"></h:outputText>
<h:inputSecret value="#{validation.password}"></h:inputSecret>
</h:panelGrid>
<h:commandButton value="Vaildate" action="#{validation.isValid}"></h:commandButton>
</h:form>
Validation.java (isValid method):
String UN="username";
String PW="password";
if (UN==username&&PW==password )
return "logged.jsf?faces-redirect=true";
return null;
}
Like, if the user enters username and password it's supposed to take him to the page logged.xhtml but it's not doing so
EDIT:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>myLoginForm</display-name>
<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>*.jsf</url-pattern>
</servlet-mapping>
</web-app>