• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can anyone please help me out?

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"));
}
}
}
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks i tried with this and it got solved now
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic