why html tags are not working inside servlet?

B_A*_*ode 1 html java servlets httpresponse

I'm new to Servlets I just trying to print a simple Html tag inside servlet response but I dunno why it doesn't print in Browser. it just print the String without getting the Html tags.

Here is the code:

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("Hi All");
        PrintWriter out =response.getWriter();
        out.println("<h2>Please complete our Customer Survey</h2>");

    }

}
Run Code Online (Sandbox Code Playgroud)

**Out Put print as **

<h2>Please complete our Customer Survey</h2>
Run Code Online (Sandbox Code Playgroud)

Please let me know how to fix this Thanks.

Joh*_*fey 5

ContentType must be set. Try this.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("Hi All");
    response.setContentType("text/html; charset=utf-8");
    PrintWriter out = response.getWriter();
    out.println("<h2>Please complete our Customer Survey</h2>");
}
Run Code Online (Sandbox Code Playgroud)