aspose file tools*
The moose likes Struts and the fly likes Can anyone please help me out? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can anyone please help me out?" Watch "Can anyone please help me out?" New topic
Author

Can anyone please help me out?

rakshini nithya
Ranch Hand

Joined: Jun 15, 2006
Posts: 39
Hi
am working in struts .
i would like to fetch the password from Loginform in another action to verify a criteria.
how can i fetch a value from one action in another action so far i have written the cod for fetching the password but it returns null.Can anyone please tell me how to fetch the value?


LoginAction

public class LoginTeamProfileAction extends Action {
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
//PropertyUtils.copyProperties(LoginValueObject, LoginForm);

System.out.println("entering in to action");
LoginTeamProfileForm loginteamprofileform=(LoginTeamProfileForm)form;
String pwd=loginteamprofileform.getPassWord();
System.out.println("pasword"+pwd);
LoginTeamProfileData loginteamprofiledata=new LoginTeamProfileData();
String password=loginteamprofiledata.dbconn();
System.out.println("pwddb"+password);
if(password.equals(pwd))
{
// Forward control to the specified success target
return (mapping.findForward("success"));
}
else
{
return (mapping.findForward("search1"));
}
}
}


My Second Action

public class ConfirmationSuccessMemberTeamProfileAction extends Action {
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{System.out.println("entering in to action");
//LoginTeamForm loginteamform=(LoginTeamForm)form;
LoginTeamProfileForm loginteamprofileform=new LoginTeamProfileForm();
String pwd=loginteamprofileform.getPassWord();
System.out.println("pasword"+pwd);
LoginTeamProfileData loginteamprofiledata=new LoginTeamProfileData();
String password=loginteamprofiledata.dbconn();
System.out.println("pwddb"+password);
if(password.equals(pwd))
{
// Forward control to the specified success target
return (mapping.findForward("success"));
}
else
{
return (mapping.findForward("search1"));
}
}
}
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you want to keep information from one action to the next, the easiest way to do this is to put it in the HttpSession object. Once it's there, you can retrieve it any time you want.

In your example, it might be a good idea to create a User bean that has the name, password, and any other information about the logged-in user you might need throughout the application. You could then put this object in the session like this:

request.getSession().setAttribute("user", user");


Then, any time you need to use it, you can access it like this:

User user = (User) request.getSession().getAttribute("user");


Merrill
Consultant, Sima Solutions
rakshini nithya
Ranch Hand

Joined: Jun 15, 2006
Posts: 39
Thanks
But how can i set the Login Form values in to the bean.
Is it like this

user.setPassWord(loginform.getPassword);
rakshini nithya
Ranch Hand

Joined: Jun 15, 2006
Posts: 39
Thanks i tried with this and it got solved now
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can anyone please help me out?