title: java.io.IOException: Corrupt form data: premature ending
body: <p>hi i get this error when i submit the form  "java.io.IOException: Corrupt form data: premature ending ",it happens when i add this code inside the existing scriptlet</p>
  
  <pre><code>String selectedValue=request.getParameter("sel1");
  //out.println("Selected Value is: "+selectedValue);
  
  String select1=request.getParameter("sel2");
  //out.println("selected values is:"+select1);
  
  String concat=selectedValue+"." +select1;
  out.println(""+concat);
  </code></pre>
  
  <p>my existing scriptlet</p>
  
  <pre><code>&lt;%@ page import="java.io.*,java.sql.*,java.util.zip.*,com.oreilly.servlet.*" %&gt;
  &lt;%
  try
   {    
     //if i include here,i can retrive the values but i cant upload the file into database,shows me "java.io.IOException: Corrupt form data: premature ending "
   String selectedValue=request.getParameter("sel1");
  //out.println("Selected Value is: "+selectedValue);
  
  String select1=request.getParameter("sel2");
  //out.println("selected values is:"+select1);
  
  String concat=selectedValue+"." +select1;
  out.println(""+concat);
  
  Connection connection = null;
  String connectionURL = "jdbc:mysql://localhost:3306/ksa";
  PreparedStatement psmnt = null;
      MultipartRequest request2=new MultipartRequest(request,"/home/adapco/Desktop/output",1024*1024*1024);
  String filename=request2.getFilesystemName("file");
  
  File f=request2.getFile("file");
  out.println(f.exists()+"----------------"+f.getAbsolutePath());
  out.print(filename);
  Class.forName("com.mysql.jdbc.Driver").newInstance();
  connection = DriverManager.getConnection(connectionURL, "root", "root");
  psmnt = connection.prepareStatement("insert into file1(file_path) values(?)");
  psmnt.setString(1, f.getPath());
  int s = psmnt.executeUpdate();
  
   //if i include here it shows me null.null
  
  String selectedValue=request.getParameter("sel1");
  //out.println("Selected Value is: "+selectedValue);
  
  String select1=request.getParameter("sel2");
  //out.println("selected values is:"+select1);
  
  String concat=selectedValue+"." +select1;
  out.println(""+concat);
  
  if(s&gt;0)
  {
   System.out.println("Uploaded successfully !");
  }
  else
  {
   System.out.println("Error!");
  }
  }
  catch(Exception e)
  {
    out.print("-----------error--------------"+e);
  }
  %&gt;
  </code></pre>
  
  <p>if i exclude the code from the existing one,it works fine.some times if i include the code after the catch or at the end of the try block,it shows me null.i need to read the index value of dropdowns and concatenate them with a dot. the error was "null.null".the actual out come should be example: 1.1.
  here is my html code</p>
  
  <pre><code>&lt;%@ page language="java" %&gt;
  &lt;HTML&gt;
     &lt;FORM ENCTYPE="multipart/form-data" ACTION="uploadFile.jsp" METHOD=POST&gt;
      &lt;center&gt;
     &lt;table bgcolor=#38ACEC&gt;
      &lt;tr&gt;
      &lt;center&gt;&lt;td colspan="2" align="center"&gt;&lt;B&gt;UPLOAD THE FILE&lt;/B&gt;&lt;center&gt;&lt;/td&gt;
       &lt;/tr&gt;
      &lt;tr&gt;&lt;td colspan="2" align="center"&gt; &lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;b&gt;Choose the file To Upload:&lt;/b&gt;&lt;/td&gt;
      &lt;td&gt;&lt;INPUT NAME="file" TYPE="file"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;select name="sel1"&gt;
       &lt;option value="1"&gt;Aerospace&lt;/option&gt;
       &lt;option value="2"&gt;Automotive&lt;/option&gt;
       &lt;option value="3"&gt;Energy&lt;/option&gt;
       &lt;option value="4"&gt;IC Engines&lt;/option&gt;
       &lt;option value="5"&gt;Wind&lt;/option&gt;
         &lt;option value="6"&gt;Turbo&lt;/option&gt;
        &lt;option value="7"&gt;IT&lt;/option&gt;
        &lt;option value="8"&gt;Training&lt;/option&gt;
       &lt;/select&gt;
       &lt;br&gt;
       &lt;select name="sel2"&gt;
       &lt;option value="1"&gt;Internal&lt;/option&gt;
       &lt;option value="2"&gt;Demos&lt;/option&gt;
       &lt;option value="3"&gt;Best Practice&lt;/option&gt;
         &lt;option value="4"&gt;Marketing&lt;/option&gt;
       &lt;option value="5"&gt;Papers &amp; public&lt;/option&gt;
       &lt;option value="6"&gt;Validation&lt;/option&gt;
       &lt;option value="7"&gt;Training&lt;/option&gt;
        &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td colspan="2" align="center"&gt; &lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;input type="submit" value="Send File"&gt; &lt;/td&gt;&lt;/tr&gt;
       &lt;table&gt;
     &lt;/center&gt;
      &lt;/FORM&gt;
     &lt;/html&gt;  
  </code></pre>