title: calling servlet on submiting formpanel in gwt
body: <p>I am trying to call a servlet when submitting the FormPanel in GWT.I am setting the url on form.setAction("myurl") and also done mapping on the web.xml but while on the form suvmit the servlet is not called.Here is the code:</p>
  
  <pre><code>public class MainEntryPoint implements EntryPoint {
  
    public void onModuleLoad() {
        AbsolutePanel panel=new AbsolutePanel();
        FileUpload upload = new FileUpload();
        upload.setName("file");
        final FormPanel form = new FormPanel();
        form.setWidget(panel);
  
   form.setMethod(FormPanel.METHOD_POST);
   form.setEncoding(FormPanel.ENCODING_MULTIPART);
  
   form.setAction("/NewServlet");
  
  RootPanel.get().add(new Label("path="+GWT.getModuleBaseURL()+"/NewServlet"));
  
   Button sub=new Button("Submit");
     sub.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                  RootPanel.get().add(new Label("In click event submiting form"));
                  try{
                  form.submit();
                  }catch(Exception e){RootPanel.get().add(new Label(e+""));}
  
         }});
  
         form.addFormHandler(new FormHandler() {
        public void onSubmit(FormSubmitEvent event) {
          // This event is fired just before the form is submitted. We can take
          // this opportunity to perform validation.
                  RootPanel.get().add(new Label("On submit"));
        }
  
        public void onSubmitComplete(FormSubmitCompleteEvent event) {
          // When the form submission is successfully completed, this event is
          // fired. Assuming the service returned a response of type text/html,
          // we can get the result text here (see the FormPanel documentation for
          // further explanation).
                  RootPanel.get().add(new Label("On submiting complete"));
        }
      });
  
  
  
   panel.add(upload);
   panel.add(sub);
  
   RootPanel.get().add(form);
  
      }
  
  }
  </code></pre>
  
  <p>Here is the web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;upload&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.fileup.client.UploadServlet2&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;NewServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;NewServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;upload&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/uploadservlet2&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;NewServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/NewServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;welcomeGWT.html&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>And NewServlet.java</p>
  
  <pre><code>public class NewServlet extends HttpServlet {
  
      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          PrintWriter out = response.getWriter();
          try {
             // /* TODO output your page here
              out.println("&lt;html&gt;");
              out.println("&lt;head&gt;");
              out.println("&lt;title&gt;Servlet NewServlet&lt;/title&gt;");  
              out.println("&lt;/head&gt;");
              out.println("&lt;body&gt;");
              out.println("&lt;h1&gt;Servlet NewServlet at " + request.getContextPath () + "&lt;/h1&gt;");
              out.println("&lt;/body&gt;");
              out.println("&lt;/html&gt;");
  
          } finally { 
              out.close();
          }
      } 
  
      // &lt;editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."&gt;
      /** 
       * Handles the HTTP &lt;code&gt;GET&lt;/code&gt; method.
       * @param request servlet request
       * @param response servlet response
       * @throws ServletException if a servlet-specific error occurs
       * @throws IOException if an I/O error occurs
       */
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          processRequest(request, response);
      } 
  
      /** 
       * Handles the HTTP &lt;code&gt;POST&lt;/code&gt; method.
       * @param request servlet request
       * @param response servlet response
       * @throws ServletException if a servlet-specific error occurs
       * @throws IOException if an I/O error occurs
       */
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          processRequest(request, response);
      }
  
      /** 
       * Returns a short description of the servlet.
       * @return a String containing servlet description
       */
      @Override
      public String getServletInfo() {
          return "Short description";
      }// &lt;/editor-fold&gt;
  
  }
  </code></pre>
  
  <p>Please tell me how can I call the NewServlet on submitting the FormPanel.</p>