How to keep html formating in jsp
<p>I need to pass html code into jsp page so I make an ajax request from the same page to update a div.</p>

<p>servlet code:</p>

<pre><code>String greetings = "&lt;h1&gt;Hello from servlet&lt;/h1&gt;";
response.setContentType("text/html;charset=UTF-8");
response.getWriter().write(greetings);
</code></pre>

<p>jsp:</p>

<pre><code>&lt;div id="ajaxGetUserServletResponse"&gt;&lt;/div&gt;
</code></pre>

<p>I get on page: <code>&lt;h1&gt;Hello from servlet&lt;/h1&gt;</code> istead of html representation of h1 tag. How to fix it to preserve html formating in jsp? </p>

<h3>Edit:</h3>

<p>Sending HTML response from server is not recommended. You could have left the <code>&lt;h1&gt;</code> tags in the JSP as well. However, if you insist on doing so this should set it up for you</p>

<pre><code>response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("&lt;h1&gt;Hello from servlet&lt;/h1&gt;");
</code></pre>