File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts form beans " Watch "struts form beans " New topic

struts form beans

Satyajeet Kadam
Ranch Hand

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

Mandar Velankar
Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 224
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:
subject: struts form beans
It's not a secret anymore!