Hello there,
There are 4 jsp page in which i want to show same category by retrieving it
from database.
What is the best way to do that? should i write a intercepter which will
retrieve Category from database and store it in session?
something like this
if (session.getAttribute("category") == null) {
CategoryDAO categoryDAO = new CategoryDAO();
categoryList = categoryDAO.listCategory();
session.setAttribute(ConfigAPP.CATEGORY_KEY, categoryList);
categoryList = (List)
session.getAttribute(ConfigAPP.CATEGORY_KEY);
System.out.println(categoryList.size());
} else {
categoryList = categoryList = (List)
session.getAttribute(ConfigAPP.CATEGORY_KEY);
}
or is there any other way to do that ?
*Dhiraj*