I have a simple (Servlet, JSP and JSTL) web application whose main functionality is to display images received from the internal server. The controller servlet sends the user to the JSP, which in turn uses a different servlet to display the resulting image on the same JSP. Further, JSP has a line similar to:
<a href="<c:out value='${imageURL}'/>"><img src="<c:out value='${imageURL}'/>" alt="image view" border="1"></a>
which raises a GET request on the servlet that generates the image, causing it to generate the image.
My question is: how do I handle the exceptions thrown by this image generation servlet?
I already have an error page defined (in web.xml) for handling ServletException in my web application, but this does not work for this servlet generating the image and leads to the following errors appearing in my Tomcat server logs:
SEVERE: Exception Processing ErrorPage[exceptionType=javax.servlet.ServletException, location=/WEB-INF/ExceptionPage.jsp] java.lang.IllegalStateException: Cannot reset buffer after response has been committed
What is my appeal in this situation?
I would like to be able to handle the Exceptions thrown from this servlet generating the image and display some error in the main user interface or redirect the user to another error page.
source share