I have a JSP that takes an Arraylist from the session object and removes the items from it. It seemed to be working fine and then out of nowhere when I navigate to that page, the page is blank. I checked the Tomcat log files and in catalina.out I am receiving a JasperException an it is showing it as being on a line with the following
for(int i; i < agentItems.size(); i++)
agentItems is the name of the ArrayList I am using. I have been debugging it and can’t seem to figure out what the problem might be. I have read that a JasperException is sometiems thrown as a JSP’s NullPointerException. Is this true or am I just completely overlooking the problem?
I have the web application running on a local machine and a intermediate server for development in which both of them have had no trouble. Why could it be that only on this server it is giving me problems?
That can be everything. You need to look a bit further in the stacktrace, peek to the
caused byorroot causepart and the trace which comes thereafter. It can be caused by many things. The JSP basically get compiled into one largetryblock and any catchedThrowablewill be wrapped into a servletcontainer specific exception likeJasperExceptionin Tomcat and clones. It boils down to this:Check the
.javafilename in the 1st line of the stacktrace, locate this in theworkdirectory of the servletcontainer and open the file in an editor. Do you see it?That said, using scriptlets is a bad practice. Use Servlets to control/preprocess/postprocess requests, use Javabeans to represent data models, use Taglibs in JSP to control the page flow and output, use Expression Language (EL) in JSP to access backend data. In your specific case, you can loop over an array or
Listusing JSTL’sc:forEachtag.