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
in doPost
Code:
request.setAttribute("list", bean.viewAll()); // set the list
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(toPage);
dispatcher.include(request,response);
response.setContentType("text/html");
writer.println("<script>alert('plan_no = " + planNo + " is added');</script>");
where bean.viewAll() return a List object
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
Code:
request.setAttribute("list", bean.viewAll());
Then, it also can solve the problem. Again, I need the "list"....
What' wrong with my code? Please give me a hand.
Thank you