1. In Action class' "execute(mapping, form, req, res)" method, we can do
SubmitForm f = (SubmitForm)form; String name = f.getName();
to retrieve "name" value. Can I simply use "String name = req.getParameter("name");" ? What's the difference ? If no difference, why bother creating a "SubmitForm" as mandatory ?
2. I learned <html:select> and <html ptionCollection>. They work well in my example but by default no item is selected. But I want to always set the first item in the listbox as selected item. I don't know what simple tag I can use to make it ?
Hi You can take the value of the field using request.getParameter().But in struts when we use struts tag libaries and ActionForms, the values will be set to the corresponding fields in the action forms.So in the respective Action class we use the form argument of the execute method to get the requried form class and the the value Suppose i have a jsp called login.jsp and i have one ActionForm class associated with as LoginForm So in my action class' executem method what i will do to get the username is LoginForm loginForm = (LoginForm)form; String username = loginForm.getUsername();
Hope you understood. Please refer jakarta struts site for more information