aspose file tools*
The moose likes Struts and the fly likes How to display data from database to JSP Page in Struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to display data from database to JSP Page in Struts2" Watch "How to display data from database to JSP Page in Struts2" New topic
Author

How to display data from database to JSP Page in Struts2

akshat Singh
Greenhorn

Joined: Apr 27, 2011
Posts: 4
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

Joined: Oct 29, 2001
Posts: 8927
    
    9

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:



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

Joined: Apr 05, 2010
Posts: 96
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display data from database to JSP Page in Struts2