GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Struts
Go To First  |  Previous Question  |  Next Question 
 Struts  |  Question 43 of 103    Print  

type="com.test.LoginForm"/>


path="/login"
type="com.test.user.login.LoginAction"
name="loginForm"
validate="false">




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();

  
Total Answers and Comments: 6 Last Update: August 24, 2009     Asked by: N 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 01, 2006 10:33:47   
venkat        

RE:

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


 
Is this answer useful? Yes | No
May 01, 2006 10:39:03   
venkat        

RE:

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..


 
Is this answer useful? Yes | No
July 18, 2006 00:15:52   
shital_patil Member Since: March 2006   Contribution: 6    

RE:

choice 4

pass (LoginForm)form).getPass();


 
Is this answer useful? Yes | No
May 02, 2007 07:01:29   
Vibs        

RE:
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

 
Is this answer useful? Yes | No
August 30, 2007 02:23:15   
sakan        

RE:
Choice 4
 
Is this answer useful? Yes | No
August 24, 2009 01:43:58   
prasad.juturi Member Since: August 2009   Contribution: 1    

RE: 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("passwor
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.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape