Possible Duplicate:
How to pass an Object from the servlet to the calling JSP
How can I pass object from servlet to JSP?
I have used the following code in the servlet side
request.setAttribute("ID", "MyID");
request.setAttribute("Name", "MyName");
RequestDispatcher dispatcher = request.getRequestDispatcher("MangeNotifications.jsp");
if (dispatcher != null){
dispatcher.forward(request, response);
}
and this code in JSP side
<td><%out.println(request.getAttribute("ID"));%> </td>
<td><%out.println(request.getAttribute("Name"));%> </td>
I get null results in the JSP Page
I think servlet’s service (doGet/doPost) method is not requested. In order to access request attributes in JSPs, you must request the
servletviaurl-patternand that way you don’t have to use session.SampleServlet.java
MangeNotifications.jsp (I presume that this file is located at root of web-context)
Now open the browser and set request url somersetting like this,