yes im accessing directly the JSP page..
Im following the MVC
pattern where my servlet will be the controller and the view will be the jsp page.
What i want is when I access the JSP page it will automatically call the servlet where it handles data retrieval from the data source like database,
then the servlet will forward the retrieved data to jsp page for display.
here is my servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
DatabaseManager dm = new DatabaseManager();
User user = dm.getUser();
request.setAttribute("user", user);
RequestDispatcher view = request.getRequestDispatcher("items.jsp");
view.forward(request, response);
}
here is the code in my jsp
<%
User s = (User)request.getAttribute("user");
out.println(s);
%>
im getting null values in my jsp page.I think when the page loads it does not call the servlet because it does not send a form or something.
Is there a better way or good way that i may be able to display a data from database in my jsp page when i first accessed it.
thanks for the reply..