• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Simple yet frustrating - Need exceptions

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic