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

JSP anyone?

Options
  • 09-11-2007 1: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 Posts: 11,980 ✭✭✭✭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 Posts: 378 ✭✭sicruise


    Use the jstl if tag...


  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


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


  • Registered Users 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 Posts: 11,980 ✭✭✭✭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