RequestDispatcher+ menu from database+ SiteMesh problem
posted 3 years ago
I'm working with SiteMesh layout system.
I made a decorator which includes other files (check code below). I want to retrive menu items from database, and print them into the decorator file. I have servlet from which I retrive data from db and which should forward this data to the menu.jsp file, but it doesn't do that. When I will type address to my index.jsp file, there are no menu items in my menu bar. This works only when I will enter on my servlet directly (/webapp-dir/MenuServlet), and here everything displays great - I have a <h1> and the menu items under it (just like in the menu.jsp file below), but the address in the address bar is not webapp/template/menu.jsp, the address is /webapp/MenuServlet. I don't how to describe it exactly, but the final effect is that, that I don't get the menu items in my pages which use the decorator. I don't want to include the servlet, I want to include menu.jsp.
btw. I have second question. I want to build my website based on the MVC. Is this correct? Model = hibernate mapping classes, Controller (place where i connect to the database and forward the data to the jsp) = servlet, view = jsp page. Or should it be Model = Java class which connects to the db and saves the data to (for example) the List, Controller = servlet where I get the List variable from Model class and forward it to the JSP page, view = jsp page ?
Servlet in which I retrive menu items and their's addresses from database (I use Hibernate):