• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Struts2MySQL

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do we create the bean class separately(not in struts2 action class) and how to pass those values in mysql using action class???
 
Bartender
Posts: 9623
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Chandana Garlapati
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Joe....

How to retrieve the auto-increment value from MySQL to JSP page using struts2??
 
Joe Ess
Bartender
Posts: 9623
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at this page from the MySQL 5.0 Reference Manual
 
Chandana Garlapati
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9623
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thanks Joe...


how to use last_insert_id() function in JSP using Struts2???
 
Joe Ess
Bartender
Posts: 9623
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally i retrieved my membernumber value in action class.
Can you tell me how to pass this value to JSP???
 
Joe Ess
Bartender
Posts: 9623
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show me how to pass that value in my code???
 
Joe Ess
Bartender
Posts: 9623
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at the Struts 2 Beginner Tutorial.
 
Chandana Garlapati
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
solved it finally,


thank you very much Joe...
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic