Clearly, the fact that leaving out the
if cause a NullPointerException means that one or both of the
subject parameters is missing.
That would suggest that the problem is in the form.
Use your browser’s web developer capabilities to find out precisely what request is being sent to your server. It looks like it would be a GET request, so the parameters should be in the request URL.