You can't make javascript access your class directly. The javascript invokes on the client while the class is in memory on your server. You'll need some sort of HTTP request to fetch the data from the server.
One popular way of doing it would be Ajax. On the button click using ajax invoke a servlet or jsp that outputs the data you want and then fill the form using javascript.
Another way would be to simply do a form submit on the button click and rebuild the page.