cannot get request params


Web tier: servlets, JSP, Web frameworks: cannot get request params

  1. cannot get request params (5 messages)

    Hello there,
    I've got an issue probably derivated by unexperience.
    I've got an html form wich should send text values and upload a file to my servlet.
    The file upload works fine but on the tomcat screen the text values are null.
    can anyone tell me where the problem is?
    Thanks in advance.

    screen code

    Start Start doGet method
    Start task step_1

    part of the servlet code

    System.out.println("Start doGet method");

    //extract the task from the request
    //String task = (String)request.getParameter("task");

    if (1 == 1) {
    System.out.println("Start task step_1");

    //retrieving values
    String title = (String)request.getParameter("title");
    String menu = (String)request.getParameter("menu");

    Html form

    <form name="createStep_1" action="<%=request.getContextPath()%>/step_1?task=step_1" method="post" enctype="multipart/form-data">
    <font>Inserire il titolo </font><input type="text" name="title" id="title" value=""><br><br>
    <font>Allegare un'immagine </font><input type="file" name="logo" id="logo" value=""><br><br>
    <font>Indicare quante voci menu sono presenti </font><input type="text" name="menu" id="menu" value="1" size="3"><br><br>
    <input type="submit" value="Continua">

    Threaded Messages (5)

  2. Here PB[ Go to top ]

    i think
    you couldnt use the filefield and the textfield in the same time.
  3. [reply][ Go to top ]

    seems quite strange, I don't think that is reason.
    And actually, I made severals test even without the file upload, and still doesn't work.
  4. [2 reply][ Go to top ]

    I made some other test, and porbably, you're not totaly wrong, in fact I tried to delete from the form the ENCTYPE="multipart/form-data" and it works, well, I can gets the text values but not the file.
    Can anyone tell me why it happens?
  5. cannot get request params[ Go to top ]

    Try sending the task parameter as a hidden parameter in the form. You are doing a post after all...

    <input type="hidden" name="task" value="step_1"/>

    Not sure if it helps, though. I haven't used the file type before..
  6. hi,

    The reason is whenever you have the upload file the other content goes like this

    Content-Disposition: form-data; name="country"

    Content-Disposition: form-data; name="phone"

    Content-Disposition: form-data; name="upload"; filename="C:\vijiroot\RobPubQueries.txt"
    Content-Type: text/plain

    select pub_no,shrinkwrap_qty from fast_publication where project_code='kai' and
    shrinkwrap_qty and pub_no in (select pub_no from fast_inv_prod where
    project_code='kai' and binding='SH WR')


    where the name="country" is the textfield and the value is "US"

    so we need to parse the data to get the textfield values