I have set my error page like this in web.xml:
java.lang.Exception
/erro
The following parameters will be set by the container when request is forwarded to the error page.
In your error JSP do this,
<%request.getAttribute("javax.servlet.error.exception").printStackTrace(new java.io.PrintWriter(out))%>;
Or Else If your error page is defined as Error page with Page Directive like,
<%@ page isErrorPage="true" import="java.io.*"%>
The exception scripting variable will be declared in the JSP. You can printing the scripting variable using a scriptlet using,
exception.printStackTrace(new java.io.PrintWriter(out));
Or,
exception.printStackTrace(response.getWriter())