How to terminal a JSP
How to terminal a JSP program.
in the program, if user's input is empty, an error message
will be displayed, and the prgram will be terminaled.
how to do?
<% if (username.length() == 0) {
out.println("Username cannot be empty.<br>\n");
terminal the program. ( how to do)
}
%>
<table .....>
</table>
</form></body></html>
[445 byte] By [
erwinba] at [2007-9-26 1:56:54]

hi
if I understand correctly, you want not to send exactly your err message, without the <table...> and so on.
Is so, concider using
<% if(hasErr()){%>
<b>You have a mistake</b>
<% } else {%>
<b>Smart boy, here is a table for you</b>
<table....>
.....
<%}%> <%-- never forget this bracket --%>
In fact you will not terminate the service method, but it is enough, but the main part will not execute anyway.
If you insist to exit the service method, place a return statement after you inform your client that he is in a mistake.
Yes, you could use System.exit(0), but it will stop the server itself, or maybe throw SecurityException (depending on the tunning the server).