added in improved input stream logic to the servlet