I am new to Struts 1.3.10 and I have a problem when I have an Action called RegistrationAction as follows:
public final class RegistrationAction extends Action{ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ RegistrationForm formBean = (RegistrationForm) form; String userid = formBean.getUserid(); String pwd = formBean.getPassword();
The user ID and password are then stored in a HashMap<String, String> with the attributes _userid and pwd .
RegistrationAction then calls the JSP if the userid and password check succeeds. But I find that in JSP, the user ID is not displayed using the following code:
<h1>Hello <bean:write name="RegistrationForm" property="_userid" />!</h1>
The corresponding ActionForm RegistrationForm contains the _userid field, as shown below:
public final class RegistrationForm extends ActionForm{ private String _userid = null; public String getUserid(){ return _userid; } public void setUserid(String userid){ _userid = userid; } ...
I know that the RegistrationForm instance is _userid because I can get the entered _userid through:
if(err == RegistrationModel.OK){ System.out.println("Here " + model.getUserid());
I thought there was a reference to RegistrationForm in JSP, such as:
<h1>Hello <bean:write name="RegistrationForm" property="_userid" />!</h1>
Will work.
Can anyone suggest where I'm wrong?
Thanks to the respondents. The page is working now.