How to change the default error page in Payara Server

1,885 views
Skip to first unread message

Ondrej Mihályi

unread,
Apr 5, 2017, 12:12:18 PM4/5/17
to Payara Forum
Hi all,

We have received a comment on the Payara blog asking how to modify/change the default Payara Server 404 error page, and I think that more people could be interested in the answer.

So the question is:

Hi, how can i remove payara name and version from default 404 page footer?

The default error page is generated from the Payara server code and it's not possible to modify it. However, it is possible to supply a completely new custom error page for every HTTP error code. I found and older stackoverflow question, leading to a more thorough blog post, which describe how to do it in GlassFish 3. The same still works in Payara Server.

I'll just describe shortly what needs to be done:

You can specify a custom error page per each application in its web.xml descriptor, or you can specify a default error page globally for all applications deployed on a virtual server.

In the web.xml, you can use the <error-page> element.

For global configuration, you would add a system property named send-error_X (where X is a number, e.g. send-error_1) for every error page you want to override. The value of the property specifies the error code, path to the html page (ideally relative to the ${com.sun.aas.instanceRoot} variable, and a reason for the error (e.g. Resource not found). If you specify more custom error pages (for different error codes), you would choose a different number in the system property name, e.g. send-error_1, send-error_2, etc.
An example would be:
send-error_1=code=404 path=${com.sun.aas.instanceRoot}/docroot/404.html reason=Resource_not_found
send-error_1=code=403 path=${com.sun.aas.instanceRoot}/docroot/404.html reason=Forbidden

I hope that helps!

Ondrej

Pravesh Mathema

unread,
Aug 10, 2021, 11:19:53 AM8/10/21
to Payara Forum
how to add for 500. 
Reply all
Reply to author
Forward
0 new messages