This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 61064
    
  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