you can use :...//initializeString address = ""; if (condition){ address = "/servlet/servlet1";}else{ address = "/servlet/servlet2";}request.getRequestDispatcher(address).forward(req,resp);...