You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kaushal Shriyan <ka...@gmail.com> on 2024/02/02 18:48:46 UTC

Return a custom page in the event of a client requesting a non-existent resource on tomcat9

Hi,

I am running tomcat version 9.0.84 on Red Hat Enterprise Linux release 8.7
(Ootpa). Is there a way to configure the server to return a custom page in
the event of a client requesting a non-existent resource.

Please guide me.

Thanks in advance.

Best Regards,

Kaushal

Re: Return a custom page in the event of a client requesting a non-existent resource on tomcat9

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Kaushal and Mark,

On 2/4/24 15:00, Mark Thomas wrote:
> On 02/02/2024 18:48, Kaushal Shriyan wrote:
>> Hi,
>>
>> I am running tomcat version 9.0.84 on Red Hat Enterprise Linux release 
>> 8.7
>> (Ootpa). Is there a way to configure the server to return a custom 
>> page in
>> the event of a client requesting a non-existent resource.
> 
> Yes.
> 
>> Please guide me.
> 
> To do this at the web application level:
> 
> Read section 10.9.2 of the Servlet 4.0 specification
> 
> 
> To do this globally, look at the errorCode.nnn attribute of the 
> ErrorReportValve
> 
> https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Error_Report_Valve

You can also deploy a ROOT web application which maps HTTP status codes 
to whatever pages you want (configured as per Servlet spec referenced 
above).

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Return a custom page in the event of a client requesting a non-existent resource on tomcat9

Posted by Mark Thomas <ma...@apache.org>.
On 02/02/2024 18:48, Kaushal Shriyan wrote:
> Hi,
> 
> I am running tomcat version 9.0.84 on Red Hat Enterprise Linux release 8.7
> (Ootpa). Is there a way to configure the server to return a custom page in
> the event of a client requesting a non-existent resource.

Yes.

> Please guide me.

To do this at the web application level:

Read section 10.9.2 of the Servlet 4.0 specification


To do this globally, look at the errorCode.nnn attribute of the 
ErrorReportValve

https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Error_Report_Valve

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org