So I have a very normal Create User servelet that has a doPost Method as follows
1) get email parameter from request 2) Check if the String is actually a valid email address
if(!UserUtils.ValidEmailAddress(Email))
{
// Exception Handeling for Invalid Email Address
// Redirect to Appropriate JSP
}
The question is if the ValidEmailAddress method returns true, then the if statment will be false and the code will skip the if statement and proceed normally ... which is exactly what I want. However, what if this turns out to be an invalide email address. The code inside the if statement will be executed, ending with a redirection to the appropriate jsp (which is great) but after that will it continue to create a user entity and assign all parameters to it(after it has redirected the request),OR upon redirection, the servelet code execution is terminated (hopefully). Would hate to have lots of nested if statements, so can someone please clarify what happens here and what is the optimum way to deal with this kind of validations. Thanks alot guys !!
Add this line after your redirect:
Alternatively, you can forward to a JSP, instead of using a redirect.
Finally, you can simply: