I have entries in a text file which I want to load into a drop down box.
I want this to happen on loading a jsp page. I could easily do this if I had a button that triggered the passing of a request object to the servlet. How do I send a request object on page load – do I need to use Javascript or is this something I can do with just jps.
Where you can populate it on the serverside. By that I mean that when you create the select box on your JSP, populate it then. For example:
If that isn’t possible, practical or desired, you’ll need to use some form of AJAX method. Personally I use jQuery for this. For example:
The above calls
/server/getanimalson page ready. It is expecting to be returned a JSON object with a list of animals that it then uses to populate the select box.There are lots of ways to skin this particular cat.