Home > Bad Code > Closing Output Stream in JSP tag

Closing Output Stream in JSP tag

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 😉

Categories: Bad Code Tags:
  1. No comments yet.
  1. No trackbacks yet.