The Artima Developer Community
Sponsored Link

Java Answers Forum
throw new Exception in servlets

1 reply on 1 page. Most recent reply: Mar 29, 2002 6:11 AM by Master

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
discovery

Posts: 1
Nickname: discovery
Registered: Mar, 2002

throw new Exception in servlets Posted: Mar 28, 2002 11:37 AM
Reply to this message Reply
Advertisement
Hi All,

Can anybody tell me how do i put debug statements in Servlet so that they are shown only on the Tomcat Console and not on the Browser window.
For example if some NullPointerException occurs.
Moreover kinldy let me know the use of the throw new Exception with example if possible...
Thanks


Master

Posts: 7
Nickname: plut
Registered: Mar, 2002

Re: throw new Exception in servlets Posted: Mar 29, 2002 6:11 AM
Reply to this message Reply
If you want to write out only to the tomcat console just use the ordinary print statement in Java.

System.out.println(" This will only appeare in the Tomcat console.");

To catch the NullPointerException just put the code inside a TRY - CATCH!


try{

The code that may generate a Exception.
}catch(NullPointerException e)
{
//This will only appeare in the Tomcat console
System.out.println("Exception occured : " +e);
}


I can't help you with the throw new Exception thing. SORRY :)

Flat View: This topic has 1 reply on 1 page
Topic: need help on applet Previous Topic   Next Topic Topic: Stop Minimizing window

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use