Bizarre getParameter in doPost method of servlet.

F

Fred

Strange problem. I have an html form that sends a POST request to a
servlet, but all the "request.getParameter()" requests are returning
null.

Here's a snippet:

public void doGet|Post(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
String baseDir = request.getParameter("baseDir");
String subDir = request.getParameter("subDir");
String description = request.getParameter("description");

if(debug)
{
log("baseDir = " + baseDir);
log("subDir = " + subDir);
log("description = " + description);
}
}

So the problem is that, even givin the exact same code for both, the
doGet method will display (in the log file) the values requested. In
the doPost method, it's always null values.

So what am I missing? I want to make it clear that doGet works (and I
can even see the values in the browser location bar).
 
A

Alex Koltun

Hi,
I suspect that the problem is in html code calling this servlet,
can you send the html you use?
anyway check the enctype attribute of the <form> tag...
is it: enctype="multipart/form-data" ?

Regards,
Alex Koltun
 
F

Fred

Hi,
I suspect that the problem is in html code calling this servlet,
can you send the html you use?
anyway check the enctype attribute of the <form> tag...
is it: enctype="multipart/form-data" ?

Regards,
Alex Koltun

Yes, that's right - among other things, I want to upload a file, but I
also want the user to specify a few options about the file. So if I
can't use the "normal" techniques when using multipart/form-data, I
suppose I have to use the same techniques that retrieve the file to
retrieve the form data?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top