Reputation: 362
I have a database with tables and values. I want to fetch that data and display it in jsp page. Don't want to write query in jsp page, separate java class, creating object values and then displaying it in html, Can anyone help me with proper structure of code.
Thanks
Upvotes: 1
Views: 2084
Reputation: 736
The right way to do that is creating a DAO and use it for all the in/outs from the DB. The controller explained by javaStudent, instanciate a DAO class and store the data in a Java Bean. Here you have good information about all that and about the correct way to program web aplication based on MVC:
I wish it could help!
Upvotes: 1
Reputation: 5138
Look up servlet. When you submit a page, you can use servlet to access the database and store the result in your request object. You can then use that request object in your jsp page to display the result.
This is a very simple approach. You may want to consider Struts MVC pattern, if you want to do it the right way.
Upvotes: 3