title: How to add variables to form and take them by doPost in java
body: <p>So I want to add four variables to my form where I'm uploading file to ftp server. </p>
  
  <p>Now I have all variables hardcoded and it looks like it:</p>
  
  <p><strong>FileUploadHandler.java</strong></p>
  
  <pre><code>public class FileUploadHandler extends HttpServlet {
      @Override
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
          ServletFileUpload upload = new ServletFileUpload();
          response.setContentType("text/plain");
  
          FileItemIterator iterator;
          try {
              iterator = upload.getItemIterator(request);
              while (iterator.hasNext()) {
                  FileItemStream item;
                  item = iterator.next();
  
                  InputStream stream = item.openStream();
                  CountriesReader countriesReader = new CountriesReader();
                  Set&lt;Country&gt; sortedCountries = countriesReader.readCountries(stream, true);
  
                  GroupOfCountries groupOfCountries = new GroupOfCountries();
                  List&lt;GroupOfCountries&gt; listOfGroupedCountriesClasses = groupOfCountries.organizeCountriesInGroups(sortedCountries);
  
                  FTPConnection ftpConnection = new FTPConnection();
                  ftpConnection.makeConnection("localhost", "21", "ftptest", "test");
  
                  Maker maker = new FTPFileMaker(ftpConnection);
                  maker.createFiles(listOfGroupedCountriesClasses, File.separator + "test123");
                  ftpConnection.makeDisconnection();               
              }
          } catch (FileUploadException e) {
              e.printStackTrace();
          } catch (RuntimeException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          } catch (JAXBException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;%@page import="java.util.Date"%&gt;
  &lt;%@page import="pl.marek.countriesmapper.reader.*" %&gt;
  &lt;%@page import="pl.marek.countriesmapper.preparer.*" %&gt;
  &lt;%@page import="pl.marek.countriesmapper.country.*" %&gt;
  &lt;%@ page language="java" contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"&gt;
  &lt;title&gt;Hello&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;form name="form1" id="form1" action="upload" method="post" enctype="multipart/form-data"&gt;
      &lt;input type="hidden" name="hiddenfield1" value="ok"&gt;
      Files to upload:
      &lt;br/&gt;
      &lt;input type="file" size="50" name="file1"&gt;
      &lt;input type="submit" value="Upload"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How can I add to form "localhost", "port", "username" and "password" and later take it to variables in FileUploadHandler class?</p>