Since you're using a .jsp, you could load the dropdown with a scriptlet before you render the <s:select>
tag.
However, it's better practice to allow the action to perform the loading and hide the .jsp files under /WEB-INF so they're not directly accessible. A common approach to perform this is the Prepare interceptor.
If you've got it in your interceptor stack, it will automatically invoke any method with the following name in your action before invoking the requested method:
- prepare{MethodName}()
- prepareDo{MethodName}()
- prepare()
That means you can do something like the following in your Action:
public class YourAction extends ActionSupport {
public String prepare(){
// populate your drop down object
}
public String view(){
// forward to your jsp
return SUCCESS;
}
}
Then all you have to do is call your action's view() method and prepare will be called first by Struts.