users@glassfish.java.net

Re: servlet: try ... finally {out.close();} <-bad idea?

From: Hassan Schroeder <hassan.schroeder_at_gmail.com>
Date: Sat, 29 May 2010 11:29:52 -0700

Since no one else commented ... :-)

On Fri, May 28, 2010 at 7:22 AM, Witold Szczerba <pljosh.mail_at_gmail.com> wrote:

> Today I was researching servlets. As far as I can see, this is very
> common conception (for example NetBeans uses such templates)
>
>   response.setContentType("text/plain");
>   PrintWriter out = response.getWriter();

> Does it sound good, or maybe this is a Glassfish bug?

I'm not sure what this has to do specifically with Glassfish, but I'd
say current best practice is to never generate output (logging aside)
from a servlet; generate values to populate your view code (JSP/EL,
Velocity, whatever). Sticking to MVC makes your life easier in a lot
of ways. :-)

YMMV,
-- 
Hassan Schroeder ------------------------ hassan.schroeder_at_gmail.com
twitter: @hassan