In GlassFish, when no error page is specified for a given web application, a default error page will be displayed. In some use cases, it is desirable to turn off the default error page. In this blog, we will summarize different ways to achieve this. 

In a Virtual Server

One can turn off the default error page in a given virtual server by specifying a property with nameerrorReportValve and value "". For instance, in domain.xml, it is as follows: 

  <config name="server-config">     <http-service>       <access-log><access-log>       <virtual-server id="server" sso-enabled="false" network-listeners="http-listener-1,http-listener-2">         <property name="errorReportValve" value=""><property>       <virtual-server>

Or one can acheive this through CLI: asadmin set configs.config.server-config.http-service.virtual-server.server.property.errorReportValve=""

In a Web Application

One can create a file with no content and then specified it as a default error page for a given application. A snapshot ofweb.xml is as follows: 

  <error-page>     <location>defaultErrorPage.jsp<location>   </error-page>

In a Servlet

One can specify a servlet init-param,org.glassfish.web.isDefaultErrorPageEnabled, inweb.xml to turn on and off default error page for a given servlet as follows: 

  <init-param>     <param-name>org.glassfish.web.isDefaultErrorPageEnabled<param-name>     <param-value>false<param-value>   </init-param>