File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes how to trap 404 error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to trap 404 error " Watch "how to trap 404 error " New topic
Author

how to trap 404 error

Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
hi all I am developing an application using tomcat+jsp.
i want to display ap proper error message if any resource is not found on the server..
my url is

http://localhost/myapp/file.jsp

if file.jsp is not not found then it should display a perticular user defined message.It should not display the server define message Like

HTTP Status 404 - /file.jsp
-------------------------------------------------------------------------
type Status report

message /file.jsp

description The requested resource (/file.jsp) is not available.
------------------------------------------------------------------------

Apache Tomcat/4.1.29


thankx
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Create an error page mapping for 404 errors in your web.xml file



Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
hi ben
thanks
I did the same for my application
it working fine

but if write url like

http://localhost/file.jsp

then it is displaying the same default error page I want to make it my self
thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

That's because it's looking for file.jsp in the default context.

Add the same error-page mapping and file to the app in
TOMCAT_HOME/webapps/ROOT.
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi Ben
thanks a lot
really u help me lot...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to trap 404 error
 
Similar Threads
HTTP Status 404 error in tomcat
I am getting this message : "Error 404--Not Found" while starting an app by Weblogic
problem with servlets
"HTTP Status 404" with Tomcat
What can cause a .war file not to show/load?