how to redirect to html page from servlet

Solutions on MaxInterview for how to redirect to html page from servlet by the best coders in the world

showing results for - "how to redirect to html page from servlet"
Michele
12 Feb 2018
1import java.io.*;
2import java.sql.Date;
3import java.util.*;
4import javax.servlet.*;
5import javax.servlet.http.*;
6
7public class PageRedirect extends HttpServlet {
8    
9   public void doGet(HttpServletRequest request, HttpServletResponse response)
10      throws ServletException, IOException {
11
12      // Set response content type
13      response.setContentType("text/html");
14
15      // New location to be redirected
16      String site = new String("http://www.photofuntoos.com");
17
18      response.setStatus(response.SC_MOVED_TEMPORARILY);
19      response.setHeader("Location", site);    
20   }
21}