title: How Do i create a link from a Java servlet in Netbeans back to a index.html or another page?
body: <p>All I am trying to do is link from the JSP back to the HTML page. I cannot find a simple example anywhere online. Also where would i put it, in the <code>doGet</code>, <code>doPost</code>, or somewhere else? I would prefer to be able to make it a button, but at this point i will take any link that works.</p>
  
  <pre><code> import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  
  @WebServlet(urlPatterns =
  {
  "/a"
  })
  public class a extends HttpServlet
  {
  
  
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException
  {
      response.setContentType("text/html;charset=UTF-8");
      try (PrintWriter out = response.getWriter())
      {
          /* TODO output your page here. You may use following sample code. */
          out.println("&lt;!DOCTYPE html&gt;");
          out.println("&lt;html&gt;");
          out.println("&lt;head&gt;");
          out.println("&lt;title&gt;Servlet a&lt;/title&gt;");            
          out.println("&lt;/head&gt;");
          out.println("&lt;body&gt;");
          out.println("&lt;h1&gt;Servlet a at " + request.getContextPath() + "&lt;/h1&gt;");
          out.println("&lt;/body&gt;");
          out.println("&lt;/html&gt;");
      }
  }
  
  
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException
  {
      processRequest(request, response);
  }
  
  
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException
  {
      processRequest(request, response);
  }
  
  
  @Override
  public String getServletInfo()
  {
      return "Short description";
  }
  </code></pre>
  
  <p>}</p>