File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Exception handling in Servlet

Robertovich Wartins

Joined: Nov 21, 2006
Posts: 16
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

Joined: Jan 10, 2002
Posts: 63844

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Exception handling in Servlet
It's not a secret anymore!