Problem is i is defined in scriplet block of java and you are trying to access it in javascript after the block is closed and hence you are not getting it,