1

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

2
  • 3
    You should try the MVC pattern. Commented May 15, 2012 at 14:34
  • 3
    possible duplicate of JSP using MVC and JDBC Commented May 15, 2012 at 14:35

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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:

http://pdf.coreservlets.com/

I wish it could help!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.