mercredi 2 novembre 2016

Using if statement to determine link based on session variable

I am working on my header page for my application and I am trying to add code that the path for the 'HOME' button depending on whether they logged in to my system through EFT or Check. I have the following code:

   <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <%  if (session.getAttribute("loginSystem") != null) {   %>
        <%  String headerAction = session.getAttribute("loginSystem").toString() ; %>
        <%  out.print("The value in header is " + headerAction) ;   %>
        <%  if(headerAction == "loginEFT") { %>
             <li><a href="EFTscreen?action=returnEFTS">Home</a></li>
        <% } else { %>
               <li><a href="Checkscreen?action=returnCHKS">Home</a></li>
        <% } } %>  

I am always going into the else part of this statement. I even put a 'out.print' to check the value of headerAction and it is showing the correct value. Is there a syntax error in the if statement or is it the placement of my <% %> that is causing the code to always hit else

Thanks

Aucun commentaire:

Enregistrer un commentaire