I have a class Products, which has the attributes name, description and price.
I intend to populate products in the application scope of my project. How do I go about achieving that?
Secondly, upon populating the products, I want to be able to display each product in a table in a JSP page. Each product will have its own table, listing its name,description and price and an add to cart button
So you want to populate it once during webapp’s lifetime? Use a
ServletContextListener.This way the products will be available in every servlet by
and in every JSP by
So you want to categorize the products? Have a
List<Category>then whereCategoryclass has aList<Product>, or use aMap<String, List<Product>>where the key is the category name.As to how to display it, that’s already been answered in your other question.