Tuesday, October 4, 2011

Show custom page for run-time exceptions occurred in servlet


In Coldfusion if you see errors in servlet with a stack trace like below:



then in order to get custom error page you need to add this code


<error-page>
<error-code>500</error-code>
<location>/500.cfm</location>
</error-page>


in default-web.xml. You can find this xml in this location C:\JRun4\servers\cfusion\SERVER-INF\.

Ref: http://livedocs.adobe.com/jrun/4/Programmers_Guide/techniques_servlet12.htm

I created the above error by capturing the form post using Live HTTP Headers add on of Firefox and changing the content length and replayed the request. When I do this then cferror was not capturing that error. So had to do this way in order to show custom error.




No comments:

Post a Comment