Archive

Archive for June 19th, 2008

Closing Output Stream in JSP tag

June 19th, 2008

Here is a code snippet from a custom JSP tag I ran into today:


try
{
out.write(hoursSelectHTML.toString());
out.flush();
}
catch (IOException e)
{
logger.error(“Exception writing to the output stream… ”, e);
}
finally
{
try
{
out.close();
}
catch (IOException e)
{
// Simply ignore this exception
}
}return SKIP_BODY;

If you are still wondering what is wrong with it, pay attention to the part where the stream is being closed ;)

Balaji Bad Code