• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anyone please help me out?

 
rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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");
 
rakshini nithya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i tried with this and it got solved now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic