• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with errorPage and isErrorPage="true"

 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I make my custom error pages using "errorPage" and "isErrorPage"
In head first Servlets and JSP they have mentioned that by making errorPage="true" we can run the page. But in my case it ends up with an tomcat error page. But using my errorPage="false" it solves the problem.
I think my syntax is wrong. Can anybody solve this problem
 
Gaurav Gambhir
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this

errorPage.jsp
<%@ page isErrorPage="true"%>
<html><body>
<strong>Divide by 0 is not allowed</strong>
</body></html>
badPage.jsp
<%@ page errorPage="errorPage.jsp"%>
<html><body>
This is bad
<% int i=10/0; %>
</body></html>
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey but I stii get the problem. by making isErrorPage="false" I can see my custom error page. But wghen it's "true" I get the vendor specific page. Can someone figure it out what's wrong with my syntax
 
Kenny Yan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From your first post, I am not sure if this is a typo or something you stated [errorPage="true"/"false"]. The errorPage attribute of the page directive is to indicate which page it goes when an exception is thrown from that jsp.
E.g.

[file : PageOne.jsp]
<%@ page errorPage="/errorpage.jsp" %>
<%=10/0%>

In case of exception thrown[in the above code, an ArithmeticException will be thrown], and the errorpage.jsp will be displayed. If you want to access your implicit exception object in the errorpage.jsp, you need to indicated in its page directive as :

<$@ page isErrorPage="true" %>

The isErroPage attribute of the page directive.

Hope this helps.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was the same thing which I did, but result is the same

Is there anything that we should declare in DD
 
Adam Czysciak
Ranch Hand
Posts: 90
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
It was the same thing which I did, but result is the same

Is there anything that we should declare in DD

A trivial question - which page do you access with your browser? errorPage.jsp or badPage.jsp?
 
Amod Mulay
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ page import="com.sisl.group.*"%>
<%@ page import="com.sisl.doorutility.*"%>
<%@ page import="java.util.Vector"%>
<%@ page errorPage="ErrorPage.jsp"%>

in this case just writing this code in your jsp

and in the ErrorPage.jsp write
<%@ page isErrorPage="true"%>

it should work
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you could post the page directive of both pages, we might spot something.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mypage.jsp
<%@ page errorPage="MyErrorPage.jsp"%>
<html>
<body>
<%
int x=10/0;
%>
</html>
</body>

my error page is,
<%@ page isErrorPage="true" %>
<html>
<body>
<H1>Error!</H1>
</html>
</body>

I accessed the mypage.jsp but it doesn't work
My making isErrorPage="false", it solves the problem
 
Kenny Yan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm...
I saw what you mean, I guess you are using IE 6. Try it with other browser like Mozilla, Fire Fox, etc...

you may check the details here :
http://issues.apache.org/bugzilla/show_bug.cgi?id=31072

disable the "Show friendly HTTP error pages" in the Advanced Settings
of your IE will make it working perfectly
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it solves the problem
but now both isErrorPage="true" and isErrorPage="false" result me in dispalying my custom page. I'm using IE. Even in firefox I got the same results.
 
Ramasubbhu Allur Kuppusamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the discussion. I benefitted from it.
 
Jyothi Pathuri
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Kenny, I learned a new concept today.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
Thanks it solves the problem
but now both isErrorPage="true" and isErrorPage="false" result me in dispalying my custom page. I'm using IE. Even in firefox I got the same results.

As it should. The isErrorPage="true" does nothing more than give your error page access to the implicit exception object.

Put ${pageContext.exception} in your error page and try it with isErrorPage="true" and then with it as false. You will see a difference.

See HF pg. 461 for more info.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mark but it didn't solve

my bad page is,
<%@ page errorPage="errorpage.jsp" %>
<html>
<body>
<%
int x=10/0;
%>
</body>
</html>

error page is,
<%@ page isErrorPage="false" %>
<html>
<body>

Error !${pageContext.exception}

</body>
</html>

but it worked for both "true" and "false"

Is anybody having this problem like me?
It is confusing. We can't prodict that every IE user to turn off friendly error messages. So this will result in failure.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody has comeup with the solution?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
but it worked for both "true" and "false"

Can you describe what "it worked" means? What do you get?
[ June 17, 2006: Message edited by: Marc Peabody ]
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It gave the custom error page which I created for both "true" and "false".
It supposed to give tomcat error page for "false"
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dilshan Edirisuriya:
It supposed to give tomcat error page for "false"


No, it's not. Who told you it should?

You did not read what I wrote:
The isErrorPage="true" does nothing more than give your error page access to the implicit exception object.

You really should read page 461 of HFSJ.
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic