Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-26-2004, 09:38 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
viewing exception of a class from jsp

i have a customer class in a package in a web module.

cust.optEmail = (rs.getString("SVEMAL")=="Y")?true:false;

that line is throwing an exception. i'm developing with netbeans 3.6

i have that code in a try/catch block .. but i don't know how to see what the exception is.

i've tried System.out.prinln() from inside the class, but that apparently doesn't print to the web page.

how can i see the exception?
__________________
Mike
sde is offline   Reply With Quote
Old 04-26-2004, 10:17 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
cust.optEmail = rs.getString("SVEMAL")=="Y"?true:false;

that line works .. i'm still curious how to view exceptions though.
__________________
Mike
sde is offline   Reply With Quote
Old 04-26-2004, 11:32 AM   #3 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
If the failure occurs while a jsp is accessing the package as a bean, I believe you can use
Code:
<%= exception.getMessage() %>
To get this to work, however, you have to know that an error occurred in the jsp page. You can use a page directive to identify an errorpage that the code branches to if it hits an error, and then from the errorpage, you can display the exception message. Note: isErrorPage="true" allows the page to access the "exception" object from the prior jsp page.

Code:
<%@ page errorPage="errorpage.jsp" %>  //in original jsp file
...

//Contents of errorpage.jsp
<%@ page isErrorPage="true" %>
<html>
<body>
The following was an exception generated by....
<blockquote>
<%= exception.getMessage() %>
</blockquote>
</body>
</html>
This comes more or less from O'Reilly's "JavaServer Pages" book. Good stuff.
technobard is offline   Reply With Quote
Old 04-26-2004, 11:36 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
thanks techno!

it's really difficult to debug classes for me right now .. i know i'm missing something.

like you pointed out .. that is only if there is an exception thrown ...

i've tried to setup breaks in the class to debug a method, but it doesn't really seem to break when i run the web app.

i suppose i can setup error variables inside my class and call them in the jsp.
__________________
Mike
sde is offline   Reply With Quote
Old 04-26-2004, 11:59 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
hey cool .. i just defined a public String var in the class named 'debug'

then in my class, i put

catch(Exception e){
debug = e.toString();
}

in my jsp:
out.println(myobject.debug);
__________________
Mike
sde is offline   Reply With Quote
Old 04-26-2004, 12:00 PM   #6 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
I think runtime exceptions are caught as well, if that helps.
Good luck!
technobard is offline   Reply With Quote
Old 04-27-2004, 04:27 AM   #7 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,151
Belisarius is on a distinguished road
I'm assuming you're using Tomcat.

The Exception.printStackTrace(), and anything printed with System.out.println(), are sent to the log file catalina.out. It's probably pretty good sized right now.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 04-28-2004, 06:30 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
sounds like a great tip be.

i'll look up the implementation.. thanks!
__________________
Mike
sde is offline   Reply With Quote
Old 04-28-2004, 12:48 PM   #9 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
Quote:
Originally posted by sde
sounds like a great tip be.
You know I finally realized that when you write "be", it's really short for Belisarius. I thought it was either some hip jargon that I'm out of touch with or really bad grammar.
technobard is offline   Reply With Quote
Old 04-28-2004, 12:58 PM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
you're pretty quick te
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
jsp: display class? sde Java 1 10-19-2004 01:02 PM
c++ class question saiz66 Standard C, C++ 3 06-09-2004 07:43 PM
to put data methods inside class or not? sde Java 2 05-25-2004 04:09 PM


All times are GMT -8. The time now is 10:07 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting