This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes How to pull data from database using JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to pull data from database using JSP?" Watch "How to pull data from database using JSP?" New topic
Author

How to pull data from database using JSP?

Swapna Gouri Kalanidhi
Ranch Hand

Joined: Mar 14, 2008
Posts: 107
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 ??


Thanks & Regards
Swapna Gouri
I "try", I "catch" and "finally" WIN !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
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.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
Consider Paul's rocket mass heater.
 
subject: How to pull data from database using JSP?