DanInMa: This is JSP code, not ASP code. JSP uses the same <%...%> notation that ASP uses. PHP had to be different and use <?...?>.
Glenn's code is correct. But as he says, it is kind of pointless.
Why assign a different value to the same <input> over and over.
Just do this, instead:
document.getElementById("txtAAESNo").value = "<%=arrAAFS[arrAAFS.length-1]%>";
The end result is the same.