• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts form beans

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am developing an application in struts using dbcp
I have mysql database.I my table i have one field of type int example user_id int.

In formbean i declaring as String



I am getting this null value for
System.out.println(" LoginActionForm.user_id===="+LoginActionForm.user_id);



Tomcat console



PLease help me
 
Mandar Velankar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not access ActionForm property directly, in execute method of your Action class , first import your LoginActionForm form bean , initialize it e.g LoginActionForm loginForm = (LoginActionForm) form;
Then called corresponding getter method on it to get value e.g

System.out.println(" LoginActionForm.user_id===="+loginForm.getUser_id());

Hope you understand that.

Regards,
Mandar Velankar
 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your solution.
but it is not in Action class it is different class that verify user login
I pasting my code below
I want it to acess in













 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like your issues might be with your class LoginActionForm. Why do you have all the properties defined as static? That would mean that properties such as user_id would be the same across all users. Also, do you expect Struts to populate this class from a form? I would wonder if Struts would populate static properties...seems like it would. If LoginActionForm is actually a form, then it should extent ActionForm (or a class that extends ActionForm).

- Brent
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic