What are the possible causes of JasperException

I have a JSP that takes Arraylist

from a session object and removes items from it. It seemed to work fine and then out of nowhere when I go to this page the page is blank. I checked the Tomcat log files and in catalina.out. I receive JasperException

and it shows it as being on the line with the following

for(int i; i < agentItems.size(); i++)

      

agentItems

is the name Arraylist

I am using. I am debugging it and cannot figure out what the problem is. I read that a JasperException

is sometiems thrown as a JSP NullPointerException

. Is this true or am I just completely ignoring the problem?

I have a web application running on a local machine and a development staging server where both of them have no problem. Why can it be that only on this server it creates problems?

+2


a source to share


2 answers


It could be anything. You need to look a little further in the stacktrace, look into the part caused by

or root cause

and the trace that comes up after that. This can be caused by many things. The JSP will basically compile into one big block try

, and any allocated Throwable

will be wrapped in a servletcontainer exception, like JasperException

in Tomcat and clones. It boils down to this:

try {
    // All translated JSP code comes here. Max 64K.
} catch (Throwable t) {
    throw new JasperException(t);
}

      

Check the file name on .java

the first line of the stacktrace, find it in work

the servletcontainer server directory and open the file in an editor. Do you see it?



However, scripting is bad practice . Use Servlets to manage requests / preprocess / post process, use Javabeans to represent data models, use Taglibs in JSP to control page flow and output, use Expression Language (EL) in JSP to access data on the server. In your specific case, you can iterate over the array or List

with a JSTL tag c:forEach

.

<c:forEach items="${agents}" var="agent">
    <p>Agent: ${agent.name}
</c:forEach>

      

+3


a source


jasperexception

can also occur when the JSP cannot access an element or an element that it receives from outside, and here it may not be able to access agentItems

. Try to provide the fully qualified class name, or import the package otherwise.



0


a source







All Articles