File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Exception handling in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Exception handling in Servlet" Watch "Exception handling in Servlet" New topic
Author

Exception handling in Servlet

Robertovich Wartins
Greenhorn

Joined: Nov 21, 2006
Posts: 16
Hello
I have servlet and service method looks like the following:



The problem is in catch block - I'm not able to obtain PrintWriter object -> "OutputStream already obtained"
Any Ideas or suggestions - how to solve this?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Simple. Don't grab it twice. Refactor your code to obtain the output stream once.

P.S. Do you really want to show the stack trace to your users?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception handling in Servlet