title: Trying to pass values from jsp to servlets
body: <p>I have a jsp file <code>discussion_new.jsp</code> through which I am trying to pass parameters to a servlet named <code>DiscussionServlet</code>, but the values are not getting passed, please help, I am attaching the following code.</p>
  
  <p>Here is <code>discussion_new.jsp</code>:  </p>
  
  <pre><code> &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
   &lt;!DOCTYPE html&gt;
  
   &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;JSP Page&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1 align="center"&gt; Start a New Discussion&lt;/h1&gt;
    &lt;div id="right-container"&gt;
  &lt;form action="DiscussionServlet" method="post"&gt;
         &lt;br&gt;
       &lt;h1 align="left"&gt;Discussion Title&lt;/h1&gt;
    &lt;textarea name="post-title" id="post-title" rows ="1" cols="90" height="50"   
      width="200"&gt;
                    &lt;/textarea&gt;
              &lt;h1 align="left"&gt;Discussion Content&lt;/h1&gt;
     &lt;textarea name="post-detail" id="post-detail" rows="18" cols="90" height="50" 
       width="200"&gt;
    &lt;/textarea&gt;
  
  &lt;input id="button-submit" type="submit" value="Post" onclick="return confirm('Do                
        you really want to make this post?');" name="submit"/&gt;        
       &lt;/form&gt;
    &lt;/div&gt;
  
     &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>And here is the <code>Servlet</code> code:  </p>
  
  <pre><code>@WebServlet(name = "DiscussionServlet", urlPatterns = {"/DiscussionServlet"})
  public class DiscussionServlet extends HttpServlet {
  
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      HttpSession s=request.getSession();
     String u_id= (String) s.getAttribute("u_id");
     String post_title=request.getParameter("post-title");
     String post_detail=request.getParameter("post-detail");
  
  
      PreparedStatement p1=null;
      try {
           Connection c1=ConnectionClass.getConnected();
           p1=c1.prepareStatement("insert into     
       discuss(id,disc_title,disc_content)values(?,?,?)");
           p1.setString(1, u_id);
           p1.setString(2, post_title);
           p1.setString(3, post_detail);    
      }
      catch(Exception e)
      {
  
      }
      finally {            
          out.close();
      }
  }
  
  @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";
  }// &lt;/editor-fold&gt;
  } 
  </code></pre>
  
  <p>There is no error with the sql syntax and attribute values, I have checked, and I have removed the extra comments also from the code . Hope somebody helps</p>