I'm creating an html form, and the user will select options from a pulldown list. The content of that list will need to be drawn from the data base.
Is it best to have the form contained in a servlet? And then the action attribute of the form will be another servlet? Since most of the form is static (other than the list contents) I thought it made sense to do this as a .jsp file.
Can I grab the list contents with a scriptlet?
There are a number of ways to pull this off. While ideally you should separate your view to JSP and your control & data gathering to servlet, the Java Standard Tag Libraries provide a quick-and-dirty way to pull the data & display it all within the JSP.
What I find is a more important question with these lists is "how often does this data change?". If you use the quick-and-dirty JSTL sql tags, every page request results in another query of the database, which might be overkill. I have a number of apps that must display a drop-down list of departments, which change infrequently (maybe every six months). In these cases, I will frequently use an application scope List, and then use a Filter to make sure the List is set, and up-to-date. I am attaching source code from one of my filters for your benefit (or at least I would, if I knew how to use attachments on this forum).
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower