title: Getting value from combobox to servlet in jsp
body: <p>I have problem with get a value from combobox in my .jsp file to servlet. 
  I use method request.getParameter i other servlets and it works. In this class it don't. 
  I was also trying to get value from text field to this servlet but also don't work. I don't have any idea how to solve this problem.</p>
  
  <p>I have combobox like that:</p>
  
  <pre><code>&lt;form action="upload" method="POST" enctype="multipart/form-data"&gt; 
              &lt;p class="folders_save"&gt;Folder:
                  &lt;select name="folders1" id="user"&gt;
                          &lt;% 
                          user = (User)session.getAttribute("user");
                          listOfFolders = user.listOfFolders(); 
                          if(listOfFolders != null){
                             for(File file : listOfFolders){
                                  out.print("&lt;option value="+file.getName()+"&gt;"+file.getName()+"&lt;/option&gt;");
                              }
                             }
                          %&gt; 
                      &lt;/select&gt;
  
                       &lt;/p&gt;
                  &lt;input class="pole" type="file" name="file" /&gt;
                  &lt;input class="wrzuc" type="submit" value="Wrzuc!"&gt;
              &lt;/form&gt;  
  </code></pre>
  
  <p>I'm tring to get value:</p>
  
  <pre><code>String folder = request.getParameter("folders1");
  </code></pre>
  
  <p>My jsp file </p>
  
  <pre><code>&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;%@ page import="tools.User" %&gt;
  &lt;%@ page import="java.io.File" %&gt;
  &lt;%@ page import="java.text.DecimalFormat" %&gt;
  &lt;%@page language="Java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;
  &lt;title&gt;Serwer dysku sieciowego &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container"&gt;
  &lt;div class="ramka_zaproszenie"&gt;
  
      &lt;% 
          File[] listOfFolders;
          User user;
          String username;
          String status = null;
          if(session.getAttribute("user")!=null){
              user = (User)session.getAttribute("user");
              username = user.getLogin();
              status = user.getType().toString();
          } else {
              username = "unknown";
          }
      %&gt;
      &lt;p class="loguj"&gt;Witaj, &lt;%= username %&gt;!&lt;/p&gt;&lt;br&gt;
      &lt;% if(session.getAttribute("user")!=null){ %&gt;
          &lt;p class="tekst"&gt;Wrzuc plik na serwer:&lt;/p&gt;
  
          &lt;form action="upload" method="POST" enctype="multipart/form-data"&gt; 
          &lt;p class="folders_save"&gt;Folder:
              &lt;select name="folders1" id="user"&gt;
                      &lt;% 
                      user = (User)session.getAttribute("user");
                      listOfFolders = user.listOfFolders(); 
                      if(listOfFolders != null){
                         for(File file : listOfFolders){
                              out.print("&lt;option value="+file.getName()+"&gt;"+file.getName()+"&lt;/option&gt;");
                          }
                         }
                      %&gt; 
                  &lt;/select&gt;
  
                   &lt;/p&gt;
              &lt;input class="pole" type="file" name="file" /&gt;
              &lt;input class="wrzuc" type="submit" value="Wrzuc!"&gt;
          &lt;/form&gt;
  
      &lt;form action="folder" method="get"&gt;
          &lt;p class="tekst"&gt; Folder: &lt;br&gt;&lt;input class="pole" id="Folder" type="text" name="folderName" /&gt; 
          &lt;br /&gt;&lt;/p&gt;
          &lt;input class="zatwierdz" type="submit" id="submit" value="Utwórz" /&gt;&lt;br&gt;
      &lt;/form&gt;
      &lt;br /&gt;
      &lt;% if(status.equalsIgnoreCase("ADMIN")){ %&gt;
          &lt;a class="wroc" href="zmiana_rozmiaru.jsp"&gt;Zmiana Pojemnosci&lt;/a&gt;
      &lt;%}%&gt;
          &lt;br /&gt;
          &lt;br /&gt; 
          &lt;p class="tekst"&gt;Posiadane pliki na serwerze:&lt;/p&gt;
  
          &lt;form method="post"&gt;
          Folder:
              &lt;select name="folders"&gt;
              &lt;option value=0 selected="selected" &gt;Wybierz folder&lt;/option&gt;
                      &lt;% 
                      user = (User)session.getAttribute("user");
                      listOfFolders = user.listOfFolders(); 
                      if(listOfFolders != null){
                         for(File file : listOfFolders){
                              out.print("&lt;option value="+file.getName()+"&gt;"+file.getName()+"&lt;/option&gt;");
                          }
                         }
                      %&gt; 
                  &lt;/select&gt; 
                  &lt;input type="submit" value="Wybierz"&gt;&lt;br&gt;
                  &lt;/form&gt;
          &lt;br /&gt;  
          Pliki z folderu: &lt;%=request.getParameter("folders")%&gt;
  
          &lt;center&gt;&lt;table id="tabela"&gt;
          &lt;tr class="alt"&gt;
          &lt;th&gt;Nazwa&lt;/th&gt;
          &lt;th&gt;Rozmiar&lt;/th&gt;
          &lt;th&gt;Pobierz&lt;/th&gt;
          &lt;th&gt;Usun&lt;/th&gt;
          &lt;/tr&gt;
          &lt;% 
          System.out.println(request.getParameter("folders"));
             user = (User)session.getAttribute("user");
             File[] listOfFiles = user.listOfFiles(request.getParameter("folders"));
             if(listOfFiles != null){
             for(File file : listOfFiles){
                  DecimalFormat twoDForm = new DecimalFormat("#.##");
                  out.print("&lt;tr class=\"alt\"&gt;&lt;td&gt;" + file.getName()+"&lt;/td&gt;&lt;td&gt;" +twoDForm.format((double)file.length()/1024.0)+" KB&lt;/td&gt;&lt;td align=center&gt; &lt;a href=\"download?filePath="+file.getAbsolutePath()+"\"&gt;&lt;img border=\"0\" src=\"downloadsmall.png\"&gt;&lt;/a&gt;&lt;/td&gt;&lt;td align=center&gt;&lt;a src=\"deletesmall.png\" href=\"delete?filePath="+file.getAbsolutePath()+"\" &gt;&lt;img border=\"0\" src=\"deletesmall.png\"&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;");
              }
             }
          %&gt;
  
          &lt;/table&gt;
          &lt;/center&gt;&lt;br&gt;
          &lt;form action="logout" method="post"&gt;
              &lt;input type="image" src="wylacznik.png" id="submit"&gt;
          &lt;/form&gt;
          &lt;br&gt;&lt;br&gt;
              &lt;%
          if (session.getAttribute("warning") != null) {
      %&gt;
      &lt;span&gt;&lt;%= session.getAttribute("warning") %&gt;&lt;/span&gt; 
      &lt;%
          session.removeAttribute("warning");
          }
      %&gt;
  
      &lt;% } %&gt;
      &lt;div class="footer"&gt;Copyright 2013 by JavaProjectTeam.&lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my servlet file </p>
  
  <pre><code>&lt;pre&gt;package servlets;
  
  import java.io.*;
  import java.sql.SQLException;
  import java.util.*;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  import javax.servlet.annotation.WebServlet;
  
  import org.apache.commons.fileupload.FileItem;
  import org.apache.commons.fileupload.disk.DiskFileItemFactory;
  import org.apache.commons.fileupload.servlet.ServletFileUpload;
  
  import java.sql.Connection;
  import java.text.DecimalFormat;
  import java.text.DecimalFormatSymbols;
  
  import tools.Connector;
  import tools.User;
  
  @WebServlet("/upload")
  public class UploadServlet extends HttpServlet {
  
     private boolean isMultipart;
     private String filePath;
     private File file ;
  
     public void init(){
        // Get the file location where it would be stored.
        filePath = getServletContext().getInitParameter("file-upload");
     }
     public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, java.io.IOException {
        // Check that we have a file upload request
        request.setCharacterEncoding("UTF-8"); 
        String folder = request.getParameter("folders1");
        HttpSession session = request.getSession(true);
        User user = (User)session.getAttribute("user");
        isMultipart = ServletFileUpload.isMultipartContent(request);
        response.setContentType("text/html");
  
        java.io.PrintWriter out = response.getWriter( );
        if( !isMultipart ){
            session.setAttribute("warning", "Nie masz zadnych plikow");
            response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
            response.setHeader("Location", "hello.jsp");
            return;
        }
        DiskFileItemFactory factory = new DiskFileItemFactory();
        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        // maximum file size to be uploaded.
        upload.setSizeMax(user.getSpace() * 1024);
  
        try{ 
        // Parse the request to get file items.
        List fileItems = upload.parseRequest(request);
  
        // Process the uploaded file items
        Iterator i = fileItems.iterator();
  
        while ( i.hasNext () ) 
        {
           FileItem fi = (FileItem)i.next();
           if ( !fi.isFormField () )  
           {
              // Get the uploaded file parameters
              String fileName = fi.getName();
              // Write the file
              if( fileName.lastIndexOf("\\") &gt;= 0 ){
                 file = new File( filePath+"\\"+user.getId()+"\\"+folder+"\\"+ 
                 fileName.substring( fileName.lastIndexOf("\\"))) ;
              }else{
                 file = new File( filePath+"\\"+user.getId()+"\\"+folder+"\\"+
                 fileName.substring(fileName.lastIndexOf("\\")+1)) ;
              }
              fi.write(file);
              System.out.println(file.getName());
              try{
                  Connection connection = new Connector().getConnection();
                  DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN);
                  otherSymbols.setDecimalSeparator('.');
                  otherSymbols.setGroupingSeparator('.'); 
                  DecimalFormat twoDForm = new DecimalFormat("#.##", otherSymbols);
                  System.out.println(twoDForm.format((double)file.length()/1024.0));
                  connection.createStatement().executeUpdate("UPDATE `users` SET `space` = `space`-"+twoDForm.format((double)file.length()/1024.0)+" where id="+user.getId());
              } catch(SQLException e){
                  e.printStackTrace();
              }
              session.setAttribute("warning", "Plik został dodany do wirtualnego dysku.");
              response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
              response.setHeader("Location", "hello.jsp");
  
           }
        }
        out.println("&lt;/body&gt;");
        out.println("&lt;/html&gt;");
     }catch(Exception ex) {
         System.out.println(ex);
          session.setAttribute("warning", "File is too big! Only "+user.getSpace()+"KB left.");
          response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
          response.setHeader("Location", "hello.jsp");
  
     }
     }
     public void doGet(HttpServletRequest request, 
                         HttpServletResponse response)
          throws ServletException, java.io.IOException {
  
          throw new ServletException("GET method used with " +
                  getClass( ).getName( )+": POST method required.");
  
  
     } 
  }&lt;code&gt;
  </code></pre>