First of all dont use scriptlets use EL and JSTL instead..
next read
This Post, it has some good comments about mixing JSTL or EL with javascript, also check the view source of your generated page to see if there is any javascript error in the function loadData().