aspose file tools*
The moose likes Struts and the fly likes Struts2MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2MySQL" Watch "Struts2MySQL" New topic
Author

Struts2MySQL

Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
how do we create the bean class separately(not in struts2 action class) and how to pass those values in mysql using action class???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Chandana Garlapati wrote:how do we create the bean class separately(not in struts2 action class)


What bean? A bean to encapsulate form data? I usually let Struts create it. See the CRUD Demo.

Chandana Garlapati wrote:
and how to pass those values in mysql using action class???


This FAQ entry was written for Struts 1.2, but I think it still applies to Struts 2.x. Struts is an implementation of the Front Controller pattern, so it has little to do with back-end tasks like database access.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
thanks Joe....

How to retrieve the auto-increment value from MySQL to JSP page using struts2??
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Have a look at this page from the MySQL 5.0 Reference Manual
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
This is my Action class


struts.xml



and JSP



And i need to retrieve MemberNumber on JSP which is generated on MySQL.
how to get that???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Did you read the link I posted? MySql provides a function to retrieve the last inserted ID.
BTW, it is bad design to put all your logic in the Action class. It's fine for experimenting, but you'll want to have a look at this page from the Struts 1.x docs.
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
ok thanks Joe...


how to use last_insert_id() function in JSP using Struts2???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

You are not going to use the function in the JSP. You are going to retrieve the value in your Action (or better, a class the Action invokes) and pass it back to a JSP.
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
Finally i retrieved my membernumber value in action class.
Can you tell me how to pass this value to JSP???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

You make the value accessible via a getter in your acton and print it out on the JSP with a JSP tag.
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
Can you show me how to pass that value in my code???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Have a look at the Struts 2 Beginner Tutorial.
Chandana Garlapati
Ranch Hand

Joined: Jul 06, 2009
Posts: 97
solved it finally,


thank you very much Joe...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2MySQL