title: HTTP Status 405 - HTTP method POST is not supported by this URL
body: <p>I am getting the error <code>HTTP Status 405 - HTTP method POST is not supported by this URL</code> when I use the following code(below) ... the line causing the trouble (apparently) is <code>getServletContext().getRequestDispatcher("/EditObject?id="+objId).forward(request, response);</code></p>
  
  <pre><code>package web.objects;
  
  import java.io.IOException;
  import java.sql.SQLException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import dao.ObjDetailsDao;
  
  @SuppressWarnings("serial")
  public class EditObjectText extends HttpServlet {
  
   public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
  
    int objId = Integer.parseInt(request.getParameter("objId"));
    String text = (String)request.getParameter("description");
  
    ObjDetailsDao oddao = new ObjDetailsDao();
     try {
  oddao.modifyText(text, objId);
   /////////////
      getServletContext().getRequestDispatcher("/EditObject?id="+objId).forward(request, response);
   ////////////
     } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     } catch (ServletException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
          }
        }
  }
  </code></pre>
  
  <p>EDIT: I added the <code>throws ServletException, IOException</code> as suggested, but this did not change the error.</p>
  
  <p>EDIT: the EditObject servlet looks like this</p>
  
  <pre><code> @SuppressWarnings("serial")
  public class EditObject extends HttpServlet{
  
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
  
          int objId = Integer.parseInt(request.getParameter("id"));
          dispPage(objId, request, response);
      }
  
      private void dispPage(int objId, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{        
  
  // ... lots of code in here
              getServletContext().getRequestDispatcher("/jsp/objectPageEdit.jsp").forward(request, response);
  
      }
  }
  </code></pre>
  
  <p>ANOTHER EDIT: So basically I can't do what I am doing. What I need is this, the user submits a post request and then I refer him/her back to a servlet which uses the Get method instead of Post. How can I do this referral without getting the error? Thanks in advance.</p>