This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Calling Servlet from  a java class  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling Servlet from  a java class  " Watch "Calling Servlet from  a java class  " New topic
Author

Calling Servlet from a java class

Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
Hi Guys,
Hi guys how can I call a servelet in java class when some method in that class finds an exception.
Thank
Neha
Prasanna KumarBP
Greenhorn

Joined: Jul 25, 2001
Posts: 21
write same code, what u do for applets :-)
-Prasanna
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
If you mean "can you somehow invoke the service() or doPost()" method to display the results of the error -- the answer is no, you can't do that. You'll have to bubble the exception up to the servlet that originally was called and handle it there.
I think you might have a more interesting question here. Is your question really "how do I handle exceptions in Servlet programming and display errors properly?"
Kyle Brown
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling Servlet from a java class
 
Similar Threads
accessing a java control within a static FormData class
JavaBeans Naming Standard
java class in XSL
book on classloaders
Wrapper Class?