Hi, I am new to jsp. I am familiar with simple jsp development using mysql and tomcat. But i want to learn how can i use Bean, DAO with jsp so that i will more like MVC. I searched on internet but i didn't find any good samples to startup. I would really appreciate if somebody can help me out with a simple demo code to demonstrate how these all work together.
Assuming MySQL Database "test" with table structure as follows:
My suggestion: Make a start, present what you have done and we can critique.
Most obvious thing to do would be to create some Java classes representing the objects you want.
They may or may not be a one to one mapping with the database tables.
Then write your DAO.
Most of the time with a DAO you want CRUD: Create, Read, Update, Delete. And potentially also a "List" operation.
For instance that might include a class "UserDAO" with method "saveUser(User user)". Said method takes your user object and saves it to the database.
Your JSP should only use your beans, and have no database queries/code
Questions to ask yourself:
How do these two tables login and users relate to one another?
What is the use case? Will that affect how we access the data?