request.getParameter(String name) do not be used in one form

request.getParameter(String name) do not be used in one formwith ENCTYPE="multipart/form-data",

this may be a bug?

please look the followed file

html file

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>Upload</title>

</head>

<body>

Uplo ad Example

<form method="POST" action="upload.jsp" ENCTYPE="multipart/form-data">

<p>

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

<input type="file" name="f1" size="20">

<input type="file" name="f2" size="20">

<input type="submit" value="submit" name="B1">

<input type="reset" value="reset" name="B2">

</p>

</form>

</body>

</html>

Deal JSP File

<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>test</title></head><body>

<h2>Sample Page</h2>

<%@ page import="java.io.*" %>

<%=request.getParameter("name")%>

</body>

</html>

the Result will be NULL

If you take out " ENCTYPE='multipart/form-data'" in the form file.you will be upload File ,because you do find file content in the request.

[1688 byte] By [zjfsamuel000] at [2007-9-26 1:38:04]
# 1

It's not a bug. This has more to do with what ENCTYPE="multipart/form-data" means.

Typically, your FORM is encoded as "application/x-www-urlencoded", which essentially is a bunch of key/value pairs which can be parsed using a method (in Java) like request.getParameter("x") or request.getParameterValues("x").

However, when you use "multipart/form-data" encoding, the form's values are NOT submitted this way. Instead they are encoded in a different format.

If you are using "multipart/form-data" forms, you can parse the parameters by using O'reillys MultipartRequest object.

Get the package @

http://www.servlets.com/cos/index.html

Good luck,

Justoon

justoon at 2007-6-29 2:25:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...