Added try-with-resources to util and serlvet methods