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

error-code using jsp

 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
default error page which tomcat generates.

Can you show us that error message ?
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What else were you expecting?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried it in other browsers?
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic