This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pull data from database using JSP?  RSS feed

 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers
I have a program where I need to pull data from MySQL database and display it on JSP page. The data should be pulled upon a click of a button by the user. How can I do this? Is there any way I can handle this?

Can anyone help me please ??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write your data access code in Java classes. Call these classes from a page controller to get the data. Forward the data to the JSP and use JSTL and EL to display it.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a servlet/controller talk to the backend and retrieve the data. Then the servlet will add the results from the backend as an attribute in the appropriate scope, and forward it to your JSP.

This is a very common task. You may want to search for MVC.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!