Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to trap 404 error

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create an error page mapping for 404 errors in your web.xml file

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben
thanks a lot
really u help me lot...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic