aspose file tools*
The moose likes Struts and the fly likes struts form beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts form beans " Watch "struts form beans " New topic
Author

struts form beans

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 215
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

Joined: Jul 31, 2006
Posts: 32
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

Joined: Oct 19, 2006
Posts: 215
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

Joined: Feb 08, 2006
Posts: 948
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts form beans
 
Similar Threads
Problem while inserting data into MS SQL table
tomcat return an error +mvc
Validate userid and password
HTTP status 500
unable to check user login using servlet+mysql