问题
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