title: File Uploading in jsp
body: <p>There is an issue  in the file uploading part. </p>
  
  <p>Here is the code</p>
  
  <pre><code>&lt;form action="uploadlogoc.jsp" method="post" enctype="multipart/form-data"&gt;
  &lt;table align="center"&gt;
  &lt;tr&gt;&lt;td&gt;
  USER:&lt;/td&gt;&lt;td&gt;&lt;select name="userDetails"&gt;
  &lt;%
  while(rs.next()){%&gt;
  &lt;option&gt;&lt;%=rs.getString("username") %&gt;&lt;/option&gt;
  &lt;%} %&gt;
  &lt;/select&gt;
  &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Subject&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="subject"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;File:&lt;/td&gt;&lt;td&gt;&lt;input type="file" name="file" size="25"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="s1" value="Uploadfile"&gt;&lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <hr>
  
  <p>Values in the subject field and username field shouldn't be passed to next page, because of the presence of enctype. When we remove it value will pass,but file is not uploaded. What is the reason?</p>
  
  <pre><code>Connection cone=null;
  Statement smt=null;
  ResultSet rs=null;
  DbConnection con=new DbConnection();
  try{
  cone=con.Connection();
  String sql="SELECT * FROM reg";
  smt=cone.createStatement();
  rs=smt.executeQuery(sql);
  }
  catch(Exception e){
  e.printStackTrace();
  }
  %&gt;
  </code></pre>