This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display data from database to JSP Page in Struts2

 
akshat Singh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Struts and want to display the Registration ID which is generating automatically by the mysql to my success page when user submits the form, please guide me how to achieve it...

My Action...



I TRIED BY THE METHOD HIGHLIGHTED IN BOLD:

I want to display the OnlineID which is generated on my JSP page, but it is showing OnlineID as 0.

My JSP:




Please help........
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New to Java? I see a couple of problems in your code. First, you declare an instance scope variable:

Then you pass it to a class method, which is totally unnecessary, because it is already accessible:

Then you create a new, but very similarly named variable in the method (Bad Idea!):

and you set the value for the local variable, but you do not set the value for the instance variable:


You also do not need to use OGNL syntax on your JSP tag (the percent sign and brackets). The JSP tag will take the property name itself as an argument:


 
Souvvik Basu
Ranch Hand
Posts: 96
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..
Can anyone please direct me to some tutorial that teaches me how to use database in a struts2 application? Searching the net, I found information in bits and pieces, but nothing comprehensive which teaches the stuff (without assuming that the reader knows the basics of how to do it).
Thanks in advance for the help...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic