If you're going to use the Struts framework, you might as well do things in the Struts way.
The "Struts way" is to associate an Action and ActionForm with a JSP, and have Struts call the Action class when the form is submitted.
When I'm writing a search page, I typically do what you're doing: Use the same JSP for both entering search criteria and displaying results. I just put <logic:notEmpty></logic:notEmpty> tags around the result table so that it's only visible if there are results to display.
I'd recommend you look into the DWR if you want more information on how this is possible.
Thanks for the reply Merrill. I'm still unclear on how to do something though.
I want to populate an html select menu in the struts framework with query results from an Oracle database. The problem is that I want to do it as soon as the web-app starts. Is there a way to accomplish this?
Joined: Feb 15, 2005
I would suggest you create an index.html file and register this file as a welcome page in your web.xml file.
In this page insert a meta tag to redirect to a Struts action like this;
Then have myAction get the data from the database, put the List in some scope (request, session, application) and then a forward specifying the JSP you want displayed.
In your JSP, include an <html:select> tag with either an <htmlptions> or <htmlptionsCollection> tag. This link give you information about how to use these tags.
If you want to populate the list of options and put it in application scope so that any page can use it and you want to do this as soon as the application starts, you need to write a class that extends org.apache.struts.action.Plugin, put your logic in the init() method, and register the plugin in your struts-config.xml file. [ July 21, 2006: Message edited by: Merrill Higginson ]