Question: Assuming the class LoginForm contains a String property named "password", how does the LoginAction class access the attribute called "password" in the above request? Explain why.Choice 1 String password = request.getParameter("password"); Choice 2 String password = request.getAttribute("password"); Choice 3 request.getParameterNames().getParameter("password"); Choice 4 String password = ((LoginForm) form).getPassword(); Choice 5 String password = form.getPassword();

Showing Answers 1 - 15 of 15 Answers

venkat

  • May 1st, 2006
 

the "Password" attribute can be Called in Action as

"String password = form.getPassword(); "  as per the FormClass..

If you are Used as an dynaActionForm For Hidden purpose

the syntax Will be <formName.set("Password",<value>)>

the Passowrd Parmeter should be mention in the strutsConfig.Xml

  Was this answer useful?  Yes

venkat

  • May 1st, 2006
 

if you set the passord value in Formbean Already Then we can Directly call that value by using " String password = form.getPassword(); "

if u Wann use that by in Action only Means just Set the Value in action as <formName.set("Password",value)> in the Form of dynaactionform, after setting the value u hav to declare that in strutsconfig.xml..

if this is not Clear Just let me know i Will Send u one Example..

  Was this answer useful?  Yes

Vibs

  • May 2nd, 2007
 

Choice 1 and Choice 4 both are correct. But idealy one should go for Choice 4 only adhering to struts framework. We need to type cast form object reference got in exectue method to particular required Action Form

Thanks

  Was this answer useful?  Yes

sakan

  • Aug 30th, 2007
 

Choice 4

  Was this answer useful?  Yes

If the values are set from a JSP, then we need to follow the request.getAttribute() method and while revalidating the fileds, the request.getParameter() method?will be fired.

The reason for the above two is as follows,
1. While setting the values in?a JSP, it is set as an argument and the same is sent to the formbean in the form of attribute. It is an attribute because we are setting the value to that particular?validation?method.

2. At the time of revalidation in the formbean,the same value is set as a parameter.? Now since we have set the attribute, at the time of revalidation in the form bean, it is taken as a parameter to that validation method.

I hope this gives you a better?idea?for your question.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions