Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
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:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Struts
Strurs2 example to fetch the data from database and display it on a JSP page
Mahabaleshwar Bhat
Greenhorn
Posts: 1
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am very new to struts2. Can anyone please give me an exaple on how to fetch the data from the databse, how to store those values in an arralyist and display the results in
JSP
page. Please give me sample code.
Thanks in advance.
-Mahabalesh
debraj mallick
Ranch Hand
Posts: 188
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
in action
public class CommonAction extends ActionSupport{ private List<EmployeeBean> employeeList; employeeList = yourService.getAllDetailsOfEmployee();// get all the employee details form database public List<EmployeeBean> getEmployeeBeanList() { return employeeList; } public void setEmployeeBeanList( List<EmployeeBean> employeeList) { this.employeeList = employeeList; } }
In JSP
<%@ taglib prefix="s" uri="/struts-tags"%> <html> <body> <table> <thead> <tr> <th></th> <th>Employee Name</th> <th>Employee Type</th> <th>Employee Sex</th> <th>Employee address</th> </tr> </thead> <tbody> <s:iterator status="stat" value="employeeList"> <tr> <td><s:property value="#stat.index+1"></s:property></td> <td><s:property value="%{username}"></s:property></td> <td><s:property value="%{type}"></s:property></td> <td><s:property value="%{sex}"></s:property></td> <td><s:property value="%{address}"></s:property></td> </tr> </s:iterator> </tbody> </table> </body> </html>
for struts2 examples :
http://www.vaannila.com/struts-2/struts-2-tutorial/struts-2-tutorial.html
struts2 tag :
http://struts.apache.org/2.0.14/docs/tag-reference.html
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
javascript pagination
pagination in jsp
Problem in Displaying JSP page
JSP and JSPF
processing sql queries from JSP
More...