How can I pass an ArrayList from one servlet another?

牧云@^-^@ 提交于 2019-12-24 23:48:16

问题


I have already sent arraylist1 from one servlet to another. It works. Now I want to pass arraylist2 to another jsp/servlet, but I get an error: java.util.nullPointer Exception. How can I resolve this?


回答1:


RequestDispatcher disp2 = request.getRequestDispatcher("NewServlet.java"); 

should be

RequestDispatcher disp2 = request.getRequestDispatcher(pathToYourServlet); 

The path is the end of the page adress: http://localhost/yourApp/pathToYourServlet




回答2:


You need to look at the full stack trace of the null pointer to establish where it is coming from. Then you should debug through that line by line to see where the null is. From there you should be able to back trace to the source. These are very general statements, but they are how I would approach your problem given the little information provided.



来源:https://stackoverflow.com/questions/4321553/how-can-i-pass-an-arraylist-from-one-servlet-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!