user291701
user291701

Reputation: 39671

Get parameter from a POST

Having a problem with a servlet posting from a form:

// index.jsp
<FORM ENCTYPE='multipart/form-data' method='POST' action='/test/uploadfile'>
  Your name: <input type="text" uploadername="name" /><br /> 
  <INPUT TYPE='file' NAME='filetoupload'>
  <INPUT TYPE='submit' VALUE='upload'>
</FORM>

// testservlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) 
    throws ServletException, IOException 
{
    String name = req.getParameter("uploadername");
    if (name == null || name.length() < 0) {
        // seems to always be empty.
    }
}

So yeah the name parameter never seems to be sent. What am I doing wrong?

Upvotes: 0

Views: 3207

Answers (2)

digitalsanctum
digitalsanctum

Reputation: 3299

You want

<input type="text" name="uploadername" />

Upvotes: 3

brabster
brabster

Reputation: 43560

It would seem that what you're trying to do isn't support by the servlet API prior to version 3.0. See this question for details and possible solutions.

Upvotes: -2

Related Questions