0

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>
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Yura
  • 125
  • 10
  • generalize your problem and improve the question. You tag it servlets but there is none in your Q that could be a part of the problem [mcve] please. And debug.... is the method called at all? https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value – Kukeltje Apr 29 '18 at 06:28
  • yes i called it in the commandbutton – Yura Apr 29 '18 at 06:30
  • Possible duplicate of [How do I compare strings in Java?](https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – Kukeltje Apr 29 '18 at 06:44
  • @Kukeltje changed the way i compared the strings but still not working! – Yura Apr 29 '18 at 06:59
  • DEBUG... 'Still not working' is not 's.m.a.r.t.' And your post is still not a [mcve].... And the change you made is not visible in the post.... please create good questions if you want good help (good indentation is a part of that. Now all seems/looks 'sloppy' and that might be an indication of the rest of your code as well... – Kukeltje Apr 29 '18 at 07:16

0 Answers0