aspose file tools*
The moose likes Servlets and the fly likes Error handling in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error handling in JSP" Watch "Error handling in JSP" New topic
Author

Error handling in JSP

Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
I've run into a problem in JDBC and I want to see the error text on the errorpage I've declared in my JSP but when the errorpage loads, the code
<%= exception.getMessage() %>
prints the output 'null' on the errorpage.
Does this mean the exception details are not getting passed properly from the first JSP?
I know the exception has to do with a resultset from a bean not being scrollable - but I'll post THAT question over on the JDBC forum.
How would I get the bean to tell the JSP the details of the error?
Thanks in advance
------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

On your error page, did you indicate that it is the error page?

I'd think it would be fairly vendor specific but the exception oject may not be populated without it...
Dave.
[This message has been edited by David O'Meara (edited October 14, 2001).]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
I suppose it is possible that the Exception does not have a message so null is the right output.
You might try exception.printStackTrace( out ) to get more information.
Bill
------------------
author of:
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
Thanks to both of you.
David:
<%@page isErrorPage="true"%> is already on the page
Bill:
I inserted the code as you suggested and I got the following error message:
An error occurred at line: 22 in the jsp file: /jsp/errorpage.jsp
Generated servlet error:
C:\Tomcat4\work\localhost\examples\jsp\errorpage$jsp.java:66: Incompatible type for method. Can't convert javax.servlet.jsp.JspWriter to java.io.PrintWriter.
out.print( exception.printStackTrace( out ) );
^
1 error
Any ideas?
Thanks very much,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by William Brogden:
I suppose it is possible that the Exception does not have a message so null is the right output.

Nice point
Hmm, streams, one of my weaknesses, you could try some thing like this:

Not incredibly pretty, (stole it from some of my other code) but it should get you started
Dave.
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI David,
I tried your code but I got these errors:

Should I be importing any special classes here?
Thanks,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

java.io.*
Dave.
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Thanks Dave,
I had tried it earlier and then removed it (silly me!)
Thing is now I'm getting the error message I don't understand it
Here it is:

and here's the bean method:

The bean works perfectly well if I don't pass any args into the createStatement() method.
Any help will be appreciated,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

As a complete stab in the dark and after looking at the description for AbstractMethodError, I'm guessing you should stop Tomcat, recompile everything you can then restart Tomcat
Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.

(Good luck, I'm going home so hopefully William Brogden or another capable soul will assist)
Dave.
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Thanks.
I restarted and recompiled everything but to no avail.
I'll have to go over the java.sql docs to see what abstract method I am invoking or not to create this error.
Bye,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error handling in JSP