Question about RequestDispatcher
Hi all, I am a green hand.
Now, I am facing a problem using include() of RequestDispatcher. The below is the part of my servlet code
where bean.viewAll() return a List object
request.setAttribute("list", bean.viewAll()); // set the list
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(toPage);
writer.println("<script>alert('plan_no = " + planNo + " is added');</script>");
I got no exception and error but a bug!!
I expect a alert will popup but it doesn't, and the worst thing is the web page only show the html code instead of the GUI.
And, I have tried to use "forward()" instead of "include()" that it really can solve the problem, however, I need the alert message.
Furthermore, I have also tried to remove the code
Then, it also can solve the problem. Again, I need the "list"....
What' wrong with my code? Please give me a hand.