updated code for servlet implementation