title: Inserting data into a database using servlet returns a blank page
body: <p>I am trying to get two inputs from an html and insert them in to my database. I have tried with bosth .jsp and .html files but no luck. When the jsp/html is called it returns a white page. Instead, I would like to prompt the html/jsp page to ask for the input. What am I doing wrong???</p>
  
  <p><strong>my eclipse tree</strong></p>
  
  <p><a href="https://i.stack.imgur.com/0DcSM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0DcSM.png" alt="enter image description here"></a></p>
  
  <p><strong>AddInfo.java servlet</strong></p>
  
  <pre><code> package controllers;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.sql.Statement;
  import javax.naming.Context;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.*;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.sql.DataSource;
  
  @WebServlet(description = "A simple database connection", urlPatterns = { "/request" })
  public class AddInfo extends HttpServlet {
      private static final long serialVersionUID = 2035938036539261609L;
      private String LOGIN_PAGE = "request.jsp";
      public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws IOException, ServletException{ 
  
              }   
      // Method to handle POST method request.
      @Override
       protected void doPost(HttpServletRequest request, HttpServletResponse response)
                  throws ServletException, IOException {
  
  
           response.setContentType("text/html;charset=UTF-8");
           PrintWriter pw = response.getWriter();
  
  
           String con, QueryResult = null;
              DataSource dataSource = null;
              Connection conn = null;
              Statement stmt = null;
              String rs = null;
  
  
        try {
              Context initContext = new InitialContext();
              Context envContext = (Context)initContext.lookup("java:/comp/env");
              dataSource = (DataSource)envContext.lookup("jdbc/testdb");
              conn  = dataSource.getConnection();
  
              String name = request.getParameter("name");  
              String date = request.getParameter("date");  
  
  
                PreparedStatement pst = conn.prepareStatement("insert into Campaign values(?,?,?)");
  
                pst.setInt(1,11);  
                pst.setString(2,name);        
                pst.setString(3,date);
  
  
                QueryResult = "Added Information!";
  
                int i = pst.executeUpdate(); 
  
                if(i!=0){  
                  pw.println("&lt;br&gt;Record has been inserted"); 
  
                  response.sendRedirect(LOGIN_PAGE);
                }  
                else{  
                  pw.println("failed to insert the data");  
                 }  
  
              } catch (SQLException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              } catch (NamingException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
              try { 
                  conn.close();
              } catch (SQLException e) {
                  e.printStackTrace();
              }
  
      }
  }
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
  
   &lt;resource-ref&gt;
    &lt;description&gt;Database&lt;/description&gt;
    &lt;res-ref-name&gt;testdb&lt;/res-ref-name&gt;
    &lt;res-type&gt;oracle.jdbc.OracleDriver&lt;/res-type&gt;
    &lt;res-auth&gt;Container&lt;/res-auth&gt;
    &lt;/resource-ref&gt;
  
    &lt;servlet&gt;
       &lt;description&gt;&lt;/description&gt;
       &lt;display-name&gt;AddInfo&lt;/display-name&gt;
       &lt;servlet-name&gt;AddInfo&lt;/servlet-name&gt;      
      &lt;servlet-class&gt;controllers.AddInfo&lt;/servlet-class&gt;
      &lt;/servlet&gt;
     &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;AddInfo&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/AddInfo&lt;/url-pattern&gt;
     &lt;/servlet-mapping&gt;
  
     &lt;welcome-file-list&gt;
     &lt;welcome-file&gt;page2.html&lt;/welcome-file&gt;
     &lt;welcome-file&gt;page2.htm&lt;/welcome-file&gt;
     &lt;welcome-file&gt;page2.jsp&lt;/welcome-file&gt;
     &lt;/welcome-file-list&gt;
  
    &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>request.html</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form method="POST" id="AddInfo" action="AddInfo"&gt;
  &lt;p&gt;
  Enter name: &lt;input type="text" name="name"&gt;&lt;br&gt;
  Enter date: &lt;input type="text" name="date"&gt;&lt;br&gt;
  &lt;/p&gt;
  &lt;br&gt;
  &lt;p&gt;
  &lt;input type="submit"&gt;
  &lt;/p&gt;&lt;br&gt;
  &lt;/form&gt;
  
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>