0

I am trying to select a value from a dropdown list in an HTML form. This is a snippet from my page:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Upload file</title>
</head>
<body>
<form action="upload" enctype="multipart/form-data" method="post">
    <table border="1">
        <tr>
            <td>CSV or TXT file:</td>
            <td><input type="file" name="csvfile" /></td>
        </tr>
        <tr>
            <td>Delimiter</td>
            <td class="tdLabel"><label for="yourDelimiter"
                class="label"> Enter your delimiter: </label></td>
            <td><select name="yourDelimiter"
                id="yourDelimiter">
                    <option value="-1">Select delimiter</option>
                    <option value="|">pipe</option>
                    <option value="\t">tab</option>
                    <option value="\s">space</option>
            </select></td>
        <tr>
            <td></td>
            <td><input type="submit" value="submit"></td>
        </tr>
    </table>
</form>
</body>
</html>

I am trying to read the entered delimiter value in my Servlet code using the below code:

String delimiter=request.getParameter("yourDelimiter");

But the selected value is never coming in the delimiter String. It is always coming as null. I am new to Web Projects. Can someone please help me to get this correct.

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
user2105024
  • 37
  • 2
  • 8
  • 2
    If you are giving the `enctype as multipart` you cant get the other parameters apart from file . you could use the `apache commons jar` for file upload – Santhosh May 20 '14 at 04:52
  • Is there a way to change the enctype so that I can read both the parameters? – user2105024 May 20 '14 at 05:00
  • see this http://stackoverflow.com/questions/15729777/servlet-get-parameter-from-multipart-form-in-tomcat-7 – Omar NourdeaN May 20 '14 at 05:01

0 Answers0