You can't compare two strings using ==
, as this operator compares objects reference rather than object content. Use equals()
method to compare strings.
That's why you need to first use authorEmail != null
to check if the parameter is present (it will be after submitting form) and then !authorEmail.isEmpty()
to check if the string is not empty. The second method is the same as !authorEmail.equals("")
.
You may also use handy StringUtils.isNotEmpty()
method.