0

I have my select tag successfully populating with the strings I want it to, but when I hit submit and try and grab the value of the select tag it returns null.

index.jsp form

<form action="ServletMain" method="post" enctype="multipart/form-data">
        <select id="file_from_server" name="file_from_server">
            <c:forEach var="file" items="${files}">
                <option><c:out value="${file.getName()}" /></option>
            </c:forEach>
        </select>
        <input type="submit">
    </form>

ServletMain doPost method

protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String fileFromServer = request.getParameter("file_from_server");

        PrintWriter pw = response.getWriter();
        pw.append(fileFromServer);
    }
user207421
  • 305,947
  • 44
  • 307
  • 483
Eric Goncalves
  • 5,253
  • 4
  • 35
  • 59
  • http://stackoverflow.com/questions/3608891/pass-variables-from-servlet-to-jsp – Reimeus Nov 26 '15 at 20:51
  • Does it work if you remove enctype="multipart/form-data" ? It is only needed when you want to upload a file. If you do want to upload a file, then look at http://stackoverflow.com/questions/2422468/how-to-upload-files-to-server-using-jsp-servlet?rq=1 – rickz Nov 27 '15 at 03:33
  • There is no RMI in this question. Don't tag indiscriminately. – user207421 Nov 28 '15 at 00:13

0 Answers0