aspose file tools*
The moose likes Servlets and the fly likes Exception Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Exception Handling" Watch "Exception Handling" New topic
Author

Exception Handling

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
In my servlet i'm calling a Stateless bean.
If any exception occurs in the bean while processing the reques, thn how can i throw that exception from the bean to the invoked servlet.

Thanks
Srini
[ October 09, 2004: Message edited by: srini vasan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

Moving to the Servlets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Just like you would catch any exception thrown in any Java class. Although some people might have better ideas for handling Exceptions once they reach a Servlet, so that the user can get a nice message instead of a stack trace.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Originally posted by Mark Spritzler:
Just like you would catch any exception thrown in any Java class. Although some people might have better ideas for handling Exceptions once they reach a Servlet, so that the user can get a nice message instead of a stack trace.

Mark


Thank you yaar .. i got the sln .

i thought we cant use the " throw exception "clause in the bean, b'coz if a throws clause is used in a method it shd either have a try & corresponding catch or a throws Clause, since the bean has a signature mentioned in the remote interface, that throws remote exception, i thought i cant add one more exception..

Srini
Senthil B Kumar
Ranch Hand

Joined: Feb 09, 2004
Posts: 140
Throwing proper Exception from the Bean is the right way to handle the exception. Instead of letting the Servlet to handle the Exception. You can print the Stack Trace on the Server Side (Log) , so that it may help you to debug.


Work like you don't need the money. Love like you've never been hated. Dance like nobody's watching. Sing like nobody's listening. Live like it's Heaven on Earth.
Currently I Reside Here WEBlog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception Handling