Final updated code with MainServlet.jva