How to pass object from Servlet to JSP?
To pass an objects from Servlet to JSP you can use session. You can pass simple object, List
//Servlet Code setNotification _sN = new setNotification(); _sN.setError("Your message"); request.setAttribute("error", _sN); RequestDispatcher rd = request.getRequestDispatcher("./settings.jsp"); rd.forward(request, response);
//JSP Code <% setNotification _sN = new setNotification(); if (request.getAttribute("error") != null) { _sN = (setNotification) request.getAttribute("error"); } %> <%= _sN.getError()%>
0 comments :