How perform validation and display error message in same form in JSP?

前端 未结 3 770
广开言路
广开言路 2020-11-22 15:43

How can I display an error message in the very same JSP when a user submits a wrong input? I do not intend to throw an exception and show an error page.

3条回答
  •  独厮守ぢ
    2020-11-22 15:59

    I'm not quite sure what you mean by "display error message". If you have a standard error handling, then you can always check for options:

    <%
        if(wrong option selected)
            throw new Exception("Invalid option selected");
    %>
    

    Of course, this is just the notion; preferably, you'd have your own exception class. But then again, I'm not quite sure what you're after.

提交回复
热议问题