How do I generate error pages dynamically instead of serving static pages? Or is this impossible?
I am working on my first Java Web App and I am trying to learn the intricacies of the web.xml configuration file. My understanding based on the documentation is that error pages are configured by specifying a static file to be served for a given HTTP status code or Java exception. For example...
This would serve a page for internal server errors
...
<error-page>
<error-code>500</error-code>
<location>/errors/http/500.html</location>
</error-page>
...
This would serve a page for servlet exceptions
...
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/errors/java/servlet_exception.html</location>
</error-page>
...
This would specify a default error page for everything
...
<error-page>
<location>/errors/index.html</location>
</error-page>
...
But how do I send this information to a script/class?
I want my error pages to be pretty standard. Maybe include a logo, the error code, and a brief message based on the error. I would like the status code or exception type to be passed as parameters to the script/class. Is there any way to do this?