Changing the page by defaul when I get an error “404 - file not found”

Hi everybody,

I would like to know how to Change the page by defaul when I get a error “404 - file not found” by my page “error404.html”. . . .

I have done the folow;

this tag is added in workspace\myproyec\deploy\tomcat\conf\web.xml:

<error-page>
<error-code>404</error-code>
<location>/error404.html</location>
</error-page>

on the hand create the error404.html in the root workspace\myproyec\deploy\tomcat\webapps\app

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>my  page error 404</title>
</head>
<body>
           my html page when get a error 404
</body>
</html>

According to the tomcat documentation, it should open my page error404.html when I get a error 404 but unfortunately when I get this error it doesn´t redirects to my page error404.html. . . . . please somebody can tell me if I have wronged or how I can do it???

thank a lot!!!

Hi,

You need to place the error404.html file in the ROOT directory.

Regards,
Gleb

Hi Gleb, thank for your awner,

could you tell me where the root will be in my proyect?

I´ve just tryed to the page error404.html in the ROOT , myproyec\deploy\tomcat\webapps but it´s not working!

Regards,
Miguel

For your convenience take a look at the demo project 404page.zip (73.7 KB). Check the following files:

  • deploy/tomcat/conf/web.xml
  • deploy/tomcat/webapps/ROOT/error404.html

Regards,
Gleb

Hi Gleb,

I have had a look to the demo proyect that you send me and I don´t find the file error404.html in deploy/tomcat/webapps/ROOT/error404.html . . . . maybe you wronged when send me the file??

propyectoVacio

Regards,
Miguel

You’re right, the archive doesn’t contain the tomcat directory. Sorry about that. Simply add the ROOT directory within webapps and add error404.html within it.

image

Hi Gleb, my problem is over, you example help me a lot, appreciate it!!

Regards,
Miguel