Pavnay

 
  • Increase font size
  • Default font size
  • Decrease font size
FrançaisEnglish

[Apache/Tomcat] Response code and 404 page

Print
Http / Tomcat
When 2 application servers run together, it's not simple to have a right management for response codes and the famous 404 page.

Where manage this page ? In httpd ? In tomcat ? How to be sure that it's correctly configured ?

When 2 application servers work on the same application, we must know which is the job of each one.
Usually, the httpd server delivers static resources aa static pages (.htm et .html), scripts (.js et .css) and images (.jpg, .gif, .png). Tomcat's job is to deliver servlets and JSP pages.

Each server is able to manage itself the error page (and its error code) when a resource is unavailable.
For httpd, it's done by the DocumentError guideline taken 2 parameters (the error code and the page which is affected). In example :
DocumentError 404 /404.html


and for tomcat it's done by the following xml block :
        <error-page>
                <error-code>404</error-code>
                <location>/404.jsp</location>
        </error-page>


The problem is : how unify these 2 "404 pages".
There are many possibilities :
  • Using 2 different pages, one for httpd and the other for tomcat
This solution is not useful because there are 2 pages to maintain when there is a graphical modification for example.

  • Using one HTML page for both servers
If we use a simple HTML page, we loose Java power and by this way the customization capability of this error page.

  • Using a JSP page for httpd and tomcat
Giving this JSP page to httpd, when an error occures because a resource is missing, this page is returned. However, there is an issue : if this page is 404.jsp page, tomcat will provide this page but the response code is 200 (resource OK) which is a problem for search engine as google.

The only "satisfying" solution providing a customizable error page with the right response code (404) is to setting an unavailable page to httpd...
For example, for httpd :
DocumentError 404 /foobar404page.jsp #Unavailable page


and for tomcat :
         <error-page>
                 <error-code>404</error-code>
                 <location>/404.jsp</location> <!-- Existing page-->
         </error-page>
 


So, when a requested static resource is unavailable, httpd will try to produce a JSP page which doesn't exist. Tomcat will return the right error page with the right code...

Comments
Add New
+/-
Write comment
Name:
Email:
 
Title:
 
:D:):(:0:shock::confused:8):lol::x:P:oops::cry:
:evil::twisted::roll::wink::!::?::idea::arrow:
 

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Actualités


AddThis Social Bookmark Button