Hello,
Firstly, apologies if this should be in the javascript forum - I wasnt sure which was most appropriate to post this question in...
I am not sure if my problem is caused by the way I am mixing java and javascript in my jsp and if it can be fixed.
If currentObservat ion.getComment( ) (java) is not null then all is well. But if it is null, instead of just setting document.commen tForm.commentBo x.value to a blank string I get a java.lang.NullP ointerException .
Am I testing for null incorrectly, or is it impossible to mix java and javascript quite like this?!
any help gratefully received
Firstly, apologies if this should be in the javascript forum - I wasnt sure which was most appropriate to post this question in...
I am not sure if my problem is caused by the way I am mixing java and javascript in my jsp and if it can be fixed.
If currentObservat ion.getComment( ) (java) is not null then all is well. But if it is null, instead of just setting document.commen tForm.commentBo x.value to a blank string I get a java.lang.NullP ointerException .
Am I testing for null incorrectly, or is it impossible to mix java and javascript quite like this?!
Code:
<script language="JavaScript" type="text/javascript">
var commentValue = "";
<%if(currentObservation.getComment()!=null){%>
document.commentForm.commentBox.value="<%=currentObservation.getComment()%>";
<%}else{%>
document.commentForm.commentBox.value = "";
<%}%>
document.commentForm.commentBox.value = "";
document.commentForm.remLen.value = (1000 - commentValue.length);
//-->
</script>
Comment