Solved

Printing stack trace in jsp

Posted on 2003-11-25
6
542 Views
Last Modified: 2010-05-18
Im trying to print the stack trace in JSP, the below does not work, how do i achieve the same effect?

}
catch(Exception e)
{
      out.print(e.printStackTrace());      
}
0
Comment
Question by:danBosh
6 Comments
 

Author Comment

by:danBosh
ID: 9816908
also how do i pass excpetions that are caused in a java bean to the browser
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9816999
Does:

e.printStackTrace( out ) ;

work?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9817000
>  also how do i pass excpetions that are caused in a java bean to the browser

throw the exception in the JavaBean, and catch it in the JSP
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 9817010
You may need to do:

catch(Exception e)
{
    out.println( "<pre>" ) ;
    e.printStackTrace( out ) ;    
    out.println( "</pre>" ) ;
}
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9822149
>> e.printStackTrace( out ) ;
this won't always work. because out is JspWriter by spec. use this:

e.printStackTrace( new java.io.PrintWriter( out ) );
0
 
LVL 1

Accepted Solution

by:
cpuburst earned 40 total points
ID: 9950647
To trap errors, you can specify errorpage entries in the web.xml file. Specify the error page you want to forward the error to . Javabean should throw an exception . Automatically the error page will be called.
You have an implicit object exception in the error page alone. Use that to print exceptions.

If you need more details let me know.

regards
cpuburst
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
After-hours service is a fact of life for most MSPs. While not the most pleasant aspect of the job, there are ways to make after-hours servicing a more profitable and organized enterprise.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question