• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to display a customized "Error 404" page?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to know if there are any ways to display a customized "Page No Found" page whenever the user references a non-existent jsp?
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by calvin ho:
I want to know if there are any ways to display a customized "Page No Found" page whenever the user references a non-existent jsp?


I think this is application server dependent.
- Peter
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think you can have a custom error page for this purpose, and based on some check/validation, at the beginning of each JSP,forward the user to that error page.
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the servlet specification provides a specific means of doing this:
<web-app>
...
<error-page>
<error-code>404</error-code>
<location>/MyCustomErrorPage.html</location>
</error-page>
...
</web-app>
All Servlet 2.2 or 2.3 compliant containers are required to implement this. Note that this entry must be in the correct place in the web.xml, after all the <servlet> and <servlet-mapping> elements.
It is worth downloading the DTD and looking through it. There are a number of features available that are not widely known. You can download it from
http://java.sun.com/j2ee/dtds/web-app_2_2.dtd
The servlet 2.3 DTD is found at
http://java.sun.com/dtd/web-app_2_3.dtd

------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
reply
    Bookmark Topic Watch Topic
  • New Topic