title: Dynamic form, with or without multipart/form-data
body: <p>I am designing a simple CRUD framework in java, where in my HTML page I have a dynamic form (2 with multipart for create and update with file upload and 1 without fileupload and multipart for delete). Server side, a request modulator checks for all the parameters using <code>request.getParameterMap();</code> and checks from this hidden type input <code>&lt;input type="hidden" name="returntype" value="Create"&gt;</code> whether its a create, update or delete operation. Based on that it will call necessary handlers.</p>
  
  <blockquote>
    <p>Note: My form enctype and encoding is set to <strong>multipart/form-data</strong> 
    Note: My paramMap.size() returns 0 here and returnType is getting null and so I am getting null pointer exception. </p>
  </blockquote>
  
  <p>If I do not use enctype and encoding at all it runs fine, but then again my file upload gives me an exception that encoding type shoud be <strong>multipart/form-data</strong>. Can anyone help me in a way that I can have a dynamic form with which I can create a CRUD? or why am I not able to use <code>request.getParameterMap();</code> with <strong>multipart/form-data</strong> Thanks :)</p>
  
  <p>Given below is the code of request modulator</p>
  
  <pre><code>public String identifyNow()throws ServletException, java.io.IOException
  {
      UploadXmlAgent uploadAgent;
      paramMap=request.getParameterMap();
      if (paramMap == null)
          throw new ServletException(
            "getParameterMap returned null in: " + getClass().getName());
  
      iterator=paramMap.entrySet().iterator();
      System.out.println(paramMap.size());
      while(iterator.hasNext())
      {
          Map.Entry me=(Map.Entry)iterator.next();
          if(me.getKey().equals("returntype"))
          {
              String[] arr=(String[])me.getValue();
              returnType=arr[0];
          }
      }
  
      //Identified based on returnType, instantiate appropriate Handler
  
      if(returnType.equals("Create"))
      {
          uploadAgent=new UploadXmlAgent(realPath,request,paramMap);
          uploadAgent.retrieveXml();
                      //SOME MORE OPERATIONS  
          return uploadAgent.uploadXml();
      }
      else if(returnType.equals("Update"))
      {
          System.out.println("Update");
          uploadAgent=new UploadXmlAgent(realPath,request,paramMap);
          uploadAgent.retrieveXml();
                      //SOME MORE OPERATIONS
          return uploadAgent.uploadXml();
      }
      else if(returnType.equals("Delete"))
      {
          //SOME OPERATIONS
      }
      return returnType;
  }
  </code></pre>