Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

struts form beans

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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













 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic