Вопрос

So I have a log in system that uses 3 inputs to log you in and all the details are in a SQL database. I want to know how to check if all three are true based on the first one but the only way I can think to do it is to use nested if loops. After I've queried the database and input data into the I have 3 if statements which I know think can't be nested.

<c:forEach var="i" begin="0" end="3">
<c:if test="${param.Login == result.rows[i]['Login']}">
<c:if test="${param.Cust_Acc_No == result.rows[i]['Cust_Acc_No']}">
<c:if test="${param.password == result.rows[i]['password']}">
<c:set var="Greeting" value="Congratulations Mr.${result.rows[i]['surname']}" scope="session"/>
</c:if>
</c:if>
</c:if>
</c:forEach>

So I want to loop through all the tuples in the table and if the login entered matches the login of the tuple then look to see if the entered account number matches and then finally the password. Then the name of person will be stored in a greeting and they'll eventually be forwarded to the accounts page and greeted and they can see all their details. Any ideas? To either make this nested or how, if possible, I can use (not entirely sure how to use that though!)

Нет правильного решения

Другие советы

I would not do those checks on my JSP page. If you want something custom for authentication I suggest to use a servlet to handle the parameters and see if you are dealing with an authorized user and use a filter to project your restricted content.

I also would like to advice you to think about using a security framework like Apache Shiro where you can create your own authentication handler.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top