displaying Companies List in JSP as select
Company is a Bean with id and name as its fields ,along with getter/setters.
displaying Companies List in JSP as Table
In Action class
public class MyAction extends ActionSupport implements SessionAware {
private ArrayList companies;
public
String execute() throws Exception {
return readDatabase();
}
private String readDatabase(){
// Database reading layer
companies = "set values from database";
return "some keyword";
}
public void setCompanies(ArrayList<Company> companies){
this.companies = companies;
}
public ArrayList<Company> getCompanies(){
return this.companies;
}
}
in struts.xml
// if putting in default package...
<package name="default" extends="struts-default">
<action name="login" class="MyAction">
<result name="some keyword">yourJSP.jsp</result>
</action>
</package>
Hope you understand the basic structure
your login jsp should redirect it to action class with some parameter so as to distinguish on which method to go if you have if condition in te execute method or no such need arise if your method is just calling a database method.
Maki Jav