Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JSP anyone?

  • 09-11-2007 12:34am
    #1
    Closed Accounts Posts: 307 ✭✭


    Hey,

    Trying to compare two variables and if they don't match forward to a different page, any ideas anyone?

    <% String pass1 = request.getParameter("password"); %>
    <% String pass2 = request.getParameter("passwordconfirm"); %>

    <% if(pass1 != pass2) {%>
    <jsp:forward page = "invalid.jsp"/>
    <% } %>

    Thanks!


Comments

  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    use
    if(!pass1.equals(pass2))


  • Closed Accounts Posts: 362 ✭✭information


    Idgeitman wrote: »
    Hey,

    Trying to compare two variables and if they don't match forward to a different page, any ideas anyone?

    <% String pass1 = request.getParameter("password"); %>
    <% String pass2 = request.getParameter("passwordconfirm"); %>

    <% if(pass1 != pass2) {%>
    <jsp:forward page = "invalid.jsp"/>
    <% } %>

    Thanks!

    http://exampledepot.com/egs/java.lang/CompareStr.html


  • Registered Users, Registered Users 2 Posts: 378 ✭✭sicruise


    Use the jstl if tag...


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Yes, I'd recommend using a tag library, it's much cleaner.


  • Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭smcelhinney


    +1 for JSTL
    makes the code so readable, its not even funny.
    <c:if test="${param.pass1 ne param.password1}">
    <jsp:forward page="/invalid.jsp">
    </c:if>
    

    EL is nice and clean too
    http://www.examulator.com/moodle/mod/resource/view.php?id=465

    although Im still f€ckin struggling with lists and iterators in JSTL.. :(


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Ah lists are easy, post up a topic if ya need help, i've done loads with it. JSTL has a for each

    also:
    <c:redirect url="blah.jsp">
    <c:param name="myparam" value="${var}"/>
    </c:redirect>
    


Advertisement