Results 1 to 5 of 5

Thread: How to check for form errors in jsp

  1. #1
    Join Date
    Feb 2008
    Posts
    4

    Question How to check for form errors in jsp

    I have a page that goes something like this:

    Code:
    <form:form>
    <form:errors path="*" cssClass="error" />
    Top half of page, including submit button
    
    If statement to check for form errors
    Bottom half of page, to be displayed only if no form errors
    </form:form>
    What is the if statement syntax? I only want to display the bottom half of the page if the validator did not find any errors to display at the top of the page.

    Thanks for your help,
    Erica

  2. #2
    Join Date
    Feb 2008
    Posts
    4

    Default

    No takers? I would've thought the solution to this would be fairly simple. If anyone happens across this thread and knows the answer, it would be much appreciated.

    Thanks again,
    Erica

  3. #3
    Join Date
    Oct 2011
    Location
    Navi mumbai, India
    Posts
    1

    Default

    using the Spring Form library works <spring:hasBindErrors name="loginPasswordForm">

  4. #4

    Default

    If you work in net beans for programming net beans also providing own error console to check all errors.

  5. #5
    Join Date
    Dec 2011
    Posts
    1

    Default

    I think that best way so far is to use:

    <c:set var="errors"><form:errors path="*" /></c:set>

    This way you will have the errors in "errors" variable and you can test:
    <c:if test="${not empty errors}"> //show what you want when errors </c:if>

    you can display the error by using ${errors}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •