aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes problem with errorPage and isErrorPage= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "problem with errorPage and isErrorPage="true"" Watch "problem with errorPage and isErrorPage="true"" New topic
Author

problem with errorPage and isErrorPage="true"

Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
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


Dilshan Edirisuriya SCJP1.4, SCWCD1.4, SCBCD 5
Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 254
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

Joined: Apr 22, 2006
Posts: 299
Thank you
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
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

Joined: Jan 24, 2006
Posts: 8
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.


SCJP 1.4 since 24 July 2004<br />
SCWCD 1.4 since 24 Jun 2006<br />
SCJD 1.4 since 12 July 2007<br />
SCEA Part 1 since 31 May 2009<br />
SCEA Part 2 Preparing<br />
SCEA Part 3 Preparing<br />
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
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

Joined: Feb 25, 2005
Posts: 90
    
    5
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?


Adam
SCJA, SCJP 5.0, SCWCD 1.4, SCBCD 5, SCEA 5
Amod Mulay
Ranch Hand

Joined: Apr 06, 2006
Posts: 33
<%@ 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

Joined: Nov 24, 2005
Posts: 14688
    
  16

If you could post the page directive of both pages, we might spot something.


[My Blog]
All roads lead to JavaRanch
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
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

Joined: Jan 24, 2006
Posts: 8
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

Joined: Apr 22, 2006
Posts: 299
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

Joined: Sep 16, 2005
Posts: 120
Thanks for the discussion. I benefitted from it.


Regards,<br />Ram.<br />SCJP 1.4
Jyothi Pathuri
Ranch Hand

Joined: Jan 29, 2006
Posts: 30
Thank You Kenny, I learned a new concept today.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
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

Joined: Apr 22, 2006
Posts: 299
Does anybody has comeup with the solution?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Apr 22, 2006
Posts: 299
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

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Apr 22, 2006
Posts: 299
Thank you
 
Consider Paul's rocket mass heater.
 
subject: problem with errorPage and isErrorPage="true"