This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes error-code using jsp 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 "error-code using jsp" Watch "error-code using jsp" New topic
Author

error-code using jsp

Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
Hello friends,

I have configured an error page to handle 500 error.
Webserver used: Tomcat 5

In DD of my application I have made the following entry

<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>

Following is the jsp page which generates the error.
<%
Boolean flag = false;
if( !flag )
{
response.sendError(500, "Access forbidden boss");
}
%>


Following is the error.jsp
<%@ page isErrorPage="true" %>
Error = <font color="Red" size="8"><%=exception.getMessage()%></font>

By doing the above settings I am unable to see the custom error page. What I see is the default error page which tomcat generates.
I am able to see the custom error page for <exception-type> tag in DD.

Can anyone please help where I am going wrong ?
Few of the members suggested that in IE please uncheck "Show friendly HTTP error messages" in Advanced tab in tools-->Options. Few others suggested that the contents should be more than 5KB. If the custom error page contents are less than 5KB then default error page is shown.

I tried all of the above things but I am unable to see the custom error page for <error-code>

Please help..
Waiting for your replies.

Thanks and Regards
Rohit.
[ May 09, 2007: Message edited by: Rohit Bhagwat ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

default error page which tomcat generates.

Can you show us that error message ?


[My Blog]
All roads lead to JavaRanch
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
Originally posted by Satou kurinosuke:

Can you show us that error message ?


HTTP Status 500 - Access forbidden boss

---------------------------------------------------------------------------

type Status report

message Access forbidden boss

description The server encountered an internal error (Access forbidden boss) that prevented it from fulfilling this request.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
What else were you expecting?


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Have you tried it in other browsers?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
Originally posted by Bosun Bello:
What else were you expecting?


I was expecting custom error page to be displayed rather than tomcat generated error page [shown above].

I have not yet tried with other browsers, might need to try for that.
But still I am wondering what can be the problem?

Thanks
Rohit.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Originally posted by Rohit Bhagwat:

I have not yet tried with other browsers, might need to try for that.
But still I am wondering what can be the problem?


Trying it in other broswers is one of the steps to try and figure that out. Stop wondering and start testing.
Suman Sharma
Ranch Hand

Joined: May 16, 2005
Posts: 72
Rohit,
Do you have the following line in your following jsp page?

<%@ page errorPage="error.jsp" %>

<%
Boolean flag = false;
if( !flag )
{
response.sendError(500, "Access forbidden boss");
}
%>
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
Originally posted by Suman Sharma:
Rohit,
Do you have the following line in your following jsp page?


I dont know what difference it will make whether it is present or not ? The problem is I am not getting redirect to error.jsp. So either it is configured in web.xml or it is declared in page directive tag. Doesnt make a difference.

The reason I have not yet tried with other browser is my client will be mostly using IE.

Thanks
Rohit.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

What is the exact version of Tomcat ?
I have 5.5, and tried it on both Firefox and IE. It worked.
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
Originally posted by Satou kurinosuke:
What is the exact version of Tomcat ?
I have 5.5, and tried it on both Firefox and IE. It worked.


Tomcat: 5.0
IE : 6.0
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Originally posted by Rohit Bhagwat:

The reason I have not yet tried with other browser is my client will be mostly using IE.


Did you stop to think that by trying it in another browser that it would help determine if the issue is with IE -- which is known to have bugs related to error pages -- or if the issue is with your code?

Try it in Firefox now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: error-code using jsp
 
Similar Threads
Custom error pages
JSP and custom Exception class
Tomcat settings in an production environment?
Error Page Not Found
response.sendError & error-page