• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

Printing stack trace in jsp

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
danBosh
Asked:
danBosh
1 Solution
 
danBoshAuthor Commented:
also how do i pass excpetions that are caused in a java bean to the browser
0
 
TimYatesCommented:
Does:

e.printStackTrace( out ) ;

work?
0
 
TimYatesCommented:
>  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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
TimYatesCommented:
You may need to do:

catch(Exception e)
{
    out.println( "<pre>" ) ;
    e.printStackTrace( out ) ;    
    out.println( "</pre>" ) ;
}
0
 
kennethxuCommented:
>> e.printStackTrace( out ) ;
this won't always work. because out is JspWriter by spec. use this:

e.printStackTrace( new java.io.PrintWriter( out ) );
0
 
cpuburstCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now