I have a welcome page called index2.html and I want to initialize this page when user sends a get request.
I have created an IndexServlet to catch get requests. Then I try to send redirect to my index page but infinite loop starts as expected. How can I initialize welcome page from servlet?
@WebServlet(name = "IndexServlet", urlPatterns = {"/"})
public class IndexServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//add some information
response.sendRedirect("index2.html");
}
}
web.xml file
<welcome-file-list>
<welcome-file>
index2.html
</welcome-file>
</welcome-file-list>