Hi All,
I have a simple
jsp where I am displaying 2 columns using html:text and c tag. When the jsp is displayed, the form values are not being populated.
I have a system.out.println() in action class and its not showing in the console. I don't know what I'm doing wrong.
I'm running this in
tomcat Here is the code snippet
jsp: aa.jsp - is in webapps\root folder
<html:form action="TestAction">
<c
ut value="${role}"/>
<html:text property="jobMessage"/>
</html:form>
struts-config.xml - which is under WEB-INF
<form-beans>
<form-bean name="testForm" type="com.test.TestForm"/>
</form-beans>
<action path="/aa"
type="com.test.TestAction"
scope="request"
name="testForm">
<forward name="success" path="/aa.jsp"/>
</action>
TestAction.class and TestForm.class are under WEB-INF\classes\com\test
TestAction
public class TestAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
System.out.println("enter");
List jobList = new ArrayList();
RunJob job = new RunJob();
job.setJobId("1");
jobList.add(job);
String msg = null;
if(jobList.size() == 0) {
msg = "There are no runjobs";
} else {
msg = jobList.size() + " runjob(s) are in the queue";
}
// set form values
TestForm testForm = (TestForm) form;
String role = "admin";
testForm.setRole(role);
testForm.setMsg(msg);
return mapping.findForward("success");
}
}
Form
public class TestForm extends ActionForm {
private String role;
private String msg;
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
Thanks in advance.
p pro