Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple yet frustrating - Need exceptions

 
mannie chaihan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.. I created an error.jsp page to output my exceptions.
I specified it as an error page <%@ page isErrorPage="true" %>
my main page is specified to use this error page. <%@ page errorPage="error.jsp"%>
and my bean code I print out the exception:
catch (Exception e) {System.out.println(e.getMessage());}
What i'm I doing wrong?
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello mannie,
what were u expecting??
do u want that the exception generated in ur bean class should be displayed in error.jsp. For that you dont have to catch the exception, so that web-container catches that exception and forwards the control to error.jsp.
 
mannie chaihan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh sorry.. yes.. that is what i'm expecting
solution from java form
Ok.. I throw and I catch.. but neither e.toString() or e.getMessage() is giving me anything???
 
mannie chaihan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.. i'm such a greenhorn.. I didn't even have a real exeception!!
argg.. thanks anyhow. :roll:
 
mannie chaihan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No It really should be an execption..
I'm trying to get a resultset.next() on an empty result set.
This should throw and exception from inside the bean..

And nothing gets printed on my page
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
two things:
First
calling resultset.next() on empty resultset wont throw an exception.
Second:
You are explicitly catching exception in your jsp, so even if some exception is generated it wont be handled by the web-container, and hence it wont be forwarded to error.jsp
 
mannie chaihan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm...
Well when I get the string from the exception within the bean and return the string..
I'm able to print the exception and it's states something like "illegal operation on empty result set."
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i said Empty ResultSet i meant that ur query was executed successfully but didn't fetched any record. In this case calling resultset.next() will return boolean false, not an exception. If you are getting an exception something is wrong else where.
As u have not provided enough data it is difficult for me to tell the exact cause of this exception.
Also what happened to ur main problem, that is displaying error in error.jsp, is it solved?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic