Assume that foo.jsp is your jsp file. and following code is the button that you want do redirect.
<h:commandButton value="Redirect" action="#{trial.enter }"/>
And now we'll check the method for directing in your java (service) class
public String enter() {
if (userName.equals("xyz") && password.equals("123")) {
return "enter";
} else {
return null;
}
}
and now this is a part of faces-config.xml file
<managed-bean>
<managed-bean-name>'class_name'</managed-bean-name>
<managed-bean-class>'package_name'</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-case>
<from-outcome>enter</from-outcome>
<to-view-id>/foo.jsp</to-view-id>
<redirect />
</navigation-case>